// open new window with specified pathRead More......
function OpenWindow(url)
{
newwindow = window.open(url, 'mywindow', 'width=500,height=400');
}
Now In .aspx.cs page or server side to use the javascript window open you have to use the following code
StringBuilder popupScript = new StringBuilder();
popupScript.Append("");
// if you are using script manager - update panel then this
ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "PopupScript", popupScript.ToString(), false);
//else
Page.RegisterStartupScript("PopupScript", popupScript.ToString());
Sunday, October 25, 2009
Open a New Window On Server Side using Javascript Code in Asp.net
Labels: Asp.net, Javascript
Saturday, October 24, 2009
Add "Select" Option To Dropdown list in Asp.net
There are many ways to add select option to dropdown list.. Here in this post i will list some of the ways: 1)
Labels: Asp.net
Friday, September 11, 2009
Tutorial using MySQL with Asp.Net
If you want to use MySQL Database with Asp.net, then here is a link which explains: http://www.15seconds.com/issue/050407.htm
The above link has explained in detail, with proper screenshots, from where to download installers, how to install with step by step screens and explanations, and also how to create sample asp.net application with MySQL database, create MySQL database (schema), create MySQL Table, Insert Data, and populate that data in asp.net gridview.
Wednesday, September 9, 2009
Using String.Format("{0}", "formatting string"}; in Asp.net
Many times we want to define formats for date, currency, number etc For example if we want date in " 09 September 2009" - String.Format{0:D} " 09 September 2009 12:30" - String.Format{0:f} Like this various formats for date, month, year, time, currency number etc can be seen at :
Labels: Asp.net
Tuesday, September 1, 2009
Inserting Data Into Table Using Select Query
In SQL, sometimes we need to select some data from one table and insert data into another table, this can be done as follows with a simple sql query:
Insert into Table1 (c1, c2, c3, c4, c5)
(Select c1, c2, c3, c4, c5 from Table2)
But make sure that both the tables have same fields, data type..
Labels: Sql Server
Monday, August 31, 2009
Textbox Watermark using Ajaxtoolkit or By Javascript
Adding Watermark to textbox can be done in two ways:
1) Using Ajax Toolkit:Read More......
<asp:TextBox runat="server" id="txtname"/><ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server"
TargetControlID="TextBox1"
WatermarkText="Type First Name Here"
WatermarkCssClass="watermarked" />
For more information on Ajax Toolkit please visit:
http://www.asp.net/ajax/
2) Using Javascript:
<asp:TextBox ID=”txtname” runat=”server” Text = “Please Enter your Name here”
onblur = “TextboxWaterMark(this, event);”
onfocus = “TextboxWaterMark(this, event);”>
</asp:TextBox>
<script type = “text/javascript”>
var Text = “Please Enter your text here”;//black
function TextboxWaterMark(txtid, evnt)
{
if(txtid.value.length == 0 && evnt.type == “blur”)
{
txtid.style.color = “set the color you want”;//red
txtid.value = Text;
}
if(txtid.value == Text && evnt.type == “focus”)
{
txtid.style.color = “set the color you want”;
txtid.value=”";
}
}
</script>
To use in code behind :
txtname.Attributes.Add(”onblur”, “TextboxWaterMark(this, event);”);
txtname.Attributes.Add(”onfocus”, “TextboxWaterMark(this, event);”);
Labels: Ajax, Asp.net, Javascript
Friday, August 28, 2009
Disable button after submit in Asp.net
Once the user has filled the form details, or did any kind of changes and clicked on submit button, if we want to prevent the duplicate data entry and show other message like "please wait.."'then we can do this as below:
<asp:Button runat="server" ID="btnsubmit" Text="Submit"Read More......
OnClick="btnsubmit_Click" UseSubmitBehavior="false"
OnClientClick="this.disabled=true;this.value='Please wait..';" />
For <asp:imagebutton> usesubmitbehavior will not work hence for this:
<asp:ImageButton runat=”server” ID=”btImageButton”
ImageUrl=”/images/submit.jpeg” OnClick=”btImageButton_Click”
OnClientClick=”javascript: Submit(this);” />
<script type=”text/javascript” language=”javascript”>
function Submit(c){
Page_ClientValidate();
if (Page_IsValid){
c.disabled = true
__doPostBack(c.name, ”);
}
return Page_IsValid;
}
</script>
For furhter reference please visit msdn : http://bit.ly/1CpMBq
Labels: Asp.net