Sharing knowledge in Project, Program, Portfolio Innovation Management (PPIM) and various Technology.
Monday, August 11, 2008
how to run exe file through javascript
<head>
<script language="javascript" type="text/javascript">
function runApp()
{s
var shell = new ActiveXObject("WScript.shell");
shell.run("notepad.exe ", 1, true);
}
</script>
</head>
<body>
<input type="button" name="button1" value="Run Notepad" onClick="runApp()" />
</body>
</html>
Monday, July 7, 2008
Dropdown validation using Javascript
Step 1:
function getcheckdrp()
{
var drp=document.getElementById("drpcheck");
if(drp=='[object]')
{
if(drp.selectedIndex==0)
{
alert("please select state");
return false;
}
}
}
step 2:
<asp:ListItem>----Select State----</asp:ListItem>
<asp:ListItem>Karnataka</asp:ListItem>
<asp:ListItem>Bangalore</asp:ListItem>
</asp:DropDownList>
<asp:Button ID="btncheckdrp" runat="server" />
step 3:
protected void Page_Load(object sender, EventArgs e)
{
btncheckdrp.Attributes.Add("onclick", "javascript:return getcheckdrp()");
}
Tuesday, June 24, 2008
How to Register User Controls and Custom Controls in Web.config
<?xml version="1.0"?>
<configuration>
<system.web>
<pages>
<controls>
<add tagPrefix="bala" src="~/Controls/Header.ascx" tagName="header"/>
<add tagPrefix="bala" src="~/Controls/Footer.ascx" tagName="footer"/>
<add tagPrefix="ControlVendor" assembly="ControlVendorAssembly"/>
</controls>
</pages>
</system.web>
</configuration>
<strong>Output:</strong>
<html>
<body>
<form id="form1" runat="server">
<bala:header ID="MyHeader" runat="server" />
</form>
</body>
</html>
Monday, June 9, 2008
Accordin Control using Dotnet
</asp:ScriptManager>
<asp:UpdatePanel ID="updatepanel1" runat="Server">
<ContentTemplate>
<table>
<tr>
<td>dsfsd</td>
</tr>
<tr>
<td>
<cc1:Accordion ID="accordin1" runat="server" RequireOpenedPane="false">
<Panes>
<cc1:AccordionPane id="accordinpane1" runat="server">
<Header>
<asp:Label ID="lbltext" runat="server" Text="bala"></asp:Label>
</Header>
<Content>
<asp:Label ID="Label1" runat="server" Text="bala1"></asp:Label>
<cc1:Accordion ID="accordin2" runat="server" RequireOpenedPane="false">
<Panes>
<cc1:AccordionPane ID="test" runat="server">
<header>
<asp:Label ID="lbltest1" runat="server" Text="testsdfsd"></asp:Label>
</header>
<Content>
<asp:Label ID="lbltest" runat="server" Text="test"></asp:Label>
</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
</Content>
</cc1:AccordionPane>
</Panes>
</cc1:Accordion>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
How to select all checkbox when i select header checkbox in datagrid.
function checkall(obj)
{
var check=obj.checked;
var len=document.form1.elements.length;
for(i=0;i<len;i++)
{
if(document.form1.elements.item(i).type=="checkbox")
{
document.form1.elements.item(i).checked=check;
}
}
}
</script>
In .Aspx grid control..
<Columns>
<asp:TemplateColumn>
<HeaderTemplate>
<input type="checkbox" id="head" onclick="checkall(this)"/>
</HeaderTemplate>
</asp:TemplateColumn>
</Columns>
<Columns>
number validatuion in textbox using Javascript
{
var check=false;
var val=obj.value;
var s=new Array("0","1","2","3","4","5","6","7","8","9");
var len=val.length;
for(i=0;i<len;i++)
{
for(j=0;j<s.length;j++)
{
if(obj.value.charAt(i)==s[j])
{
check=false
break;
}
else
{
check=true
}
}
}
if(check==true)
{
obj.value="";
obj.focus();
alert("Please type valid number");
return false;
}
}
Note:Call using onkey up event in html..
<asp:TextBox ID="txtbox" runat="server" onkeyup="javascript:return typecheck(this)" ></asp:TextBox>
how to search textbox value in dropdownlist Using Javascript
<asp:DropDownList ID="drpt" runat="server">
<asp:ListItem Text="text">ss</asp:ListItem>
<asp:ListItem Text="text">ss1</asp:ListItem>
<asp:ListItem Text="text">ss2</asp:ListItem>
<asp:ListItem Text="text">ss3</asp:ListItem>
<script language="javascript">
function getValue(obj)
{
var d=obj.value;
var dro=document.getElementById("drpt");
var drplen=document.getElementById("drpt").options.length
var i;
for(i=0;i<drplen;i++)
{
if(document.getElementById("drpt").options[i].value==d)
{
document.getElementById("drpt").selectedIndex=i;
}
}
}
</asp:DropDownList>
</script>
Sunday, June 8, 2008
Adding rows in DataGrid
DataRow dr = dtg.NewRow();
dr["Item_ID"]="ItemID";
dr["Item_Name"]="Item Name";
dr["Item_Desc"]="Item Description";
dr["Item_Amount"]="$15.65";
dtg.Rows.Add(dr);
DataGrid1.DataSource = dtg;
It will work for windows.
If you use DataGrid in ASP then you will have to keep DataTable in Session:
DataTable dtg = new DataTable();
if (Session["SampleDataTable"]==null)
{
DataColumn dc;
dc = new DataColumn("Item_ID",System.Type.GetType("System.String"));
dtg.Columns.Add(dc);
dc = new DataColumn("Item_Name",System.Type.GetType("System.String"));
dtg.Columns.Add(dc);
dc = new DataColumn("Item_Desc",System.Type.GetType("System.String"));
dtg.Columns.Add(dc);
dc = new DataColumn("Item_Amount",System.Type.GetType("System.String"));
dtg.Columns.Add(dc);
}
else {dtg = (DataTable) Session["SampleDataTable"];}
DataRow dr = dtg.NewRow();
dr["Item_ID"]="ItemID";
dr["Item_Name"]="Item Name";
dr["Item_Desc"]="Item Description";
dr["Item_Amount"]="$15.35;
dtg.Rows.Add(dr);
DataGrid1.DataSource=dtg;
DataGrid1.PageSize+=1;
DataGrid1.DataBind();
Session["SampleDataTable"]=dtg;
Tuesday, June 3, 2008
Windows Communication Foundation (WCF) features
• Facilitates interoperability through WS-* standards
• WS-Trust. Uses the secure messaging mechanisms of WS-Security
• WS-SecureConversation
• WS-Federation
• WS-SecurityPolicy
• Confidentiality – keeping messages private
• Authentication – verifying claimed identity
• Uses transport-level protocol (like HTTPS); only point-to-point secure
• Uses WS-Security; less efficient but secure from end to end
• SOAP Message Security (OASIS)
Reliable Messaging
• Provides for SOAP messages what TCP provides for IP packets
• Ensures messages are exactly once
• Handles lost messages and duplicates
• End-to-end reliability (vs. transport reliability of TCP)
Queues
• Leverages Microsoft Message Queuing (MSMQ) as a transport
• Enables loosely coupled applications and disconnected operations
Transactions
• Takes advantage of System.Transactions in .NET 2.0
• Supports WS-AtomicTransaction
Compatibility
COM+
• Extend COM+ components as Web services
• Service derived from COM+ interface
COM
• Moniker support (GetObject) for usage of WCF services from COM-based applications
Debugging the wcf Service in client side
step1:
<compilation debug=true>
step2:
<servicedebug includeExceptionDetailInfaults="true"/>
Thursday, May 29, 2008
Syndication on WCF
Restart Http Service using Command prompt
step2: type "net start http"
step3: end
Monday, April 21, 2008
Disable Copy and Paste for greater website security
Removing Xml element in two ways
<?xml version="1.0" encoding="utf-8" ?><bookstore> <books> <book genre="reference"> <title>World Atlas</title> </book> <book genre="reference"> <title>World Atlas</title> </book> </books></bookstore>
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("test.xml"));
XmlElement root = xmldoc.DocumentElement;
root.RemoveChild(root.SelectNodes("books/book"));
root.RemoveChild(root.RemoveChild(root.FirstChild));
Replacing xml attribute in two ways
<?xml version="1.0" encoding="utf-8" ?><bookstore> <books> <book genre="reference"> <title>World Atlas</title> </book> <book genre="reference"> <title>World Atlas</title> </book> </books></bookstore>
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Server.MapPath("test.xml"));
XmlElement root = xmldoc.DocumentElement;
XmlNodeList nodes = root.SelectNodes("books/book");
////////////////////////////////Replaceing Attribute value using xml///////////////////////////////
foreach (XmlNode xn in nodes)
{
xn.Attributes[0].Value = "NA";
}
////////////////////////////////Replaceing Attribute value using xml///////////////////////////////
foreach (XmlNode xn1 in nodes)
{
XmlNode dd = xn1.SelectSingleNode("@genre");
}
How to get the path for "My Documents" and other system folders?
Sunday, April 20, 2008
JSON
JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.
JSON is built on two structures:
1) A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array.
2) An ordered list of values. In most languages, this is realized as an array, vector, list, or sequence.
Installation for Dotnet
http://sourceforge.net/project/showfiles.php?group_id=205597
An easy way to build connection string.
1) Open a New notepad and save it with "udl" extension, suppose "New.udl".
2) Now you will see that it's icon is changed.
3) Open it, you will find Data Link properties dialog box.
4) For SQl Server connection string select Microsoft OLE DB Provider For SQL Server in Provider Tab.
5) Click button "Next" or select Connection Tab
6) Here you can select all connection details and press button
Test Connection. If it is successful close this dialog box.
7) Now open this file using "Notepad", you will find the connection string. Though it is built for OLE DB
type of connection, you can use for SQL Server connection by removing Provider attribute.
NOTE: If you are using SQL Authentication with password, then check the checkbox Allow Saving Password.
This is necessary so that password appears in connection string.
Thursday, April 17, 2008
Paging In Sqlserver 2005
FROM (SELECT ROW_NUMBER() OVER(ORDER BY person) AS
rownum, person, income FROM Salaries) AS Salaries1
WHERE rownum >= 5 AND rownum <= 9
ORDER BY income
Wednesday, April 16, 2008
How to show Modal and Modeless dialog windows in Javascript
When you show a modal dialog the window remains on top of other windows until the user explicitly closes it.
window.showModalDialog("Test.html","dialogWidth:400px; dialogHeight:225px; status:no; center:yes");
When you show a modeless dialog the window remains on top of other windows, but you can still access the other windows.
window.showModalessDialog("Test.html","dialogWidth:400px; dialogHeight:225px; status:no; center:yes");