as
-
Upload
vinoth-tamilarasan -
Category
Documents
-
view
58 -
download
0
Transcript of as
ASP.NET Example By Saiful Alam
Ebook Version 0.2
Last updated 20-March-2011 Please visit asp-net-example.blogspot.com for latest ebook version
About this ebook version This is a free version of asp.net example ebook. You can share this version with your friends. You also can distribute this version in your website or blogs. For any question feel free to mail me: [email protected]
Example 1
How to create string array in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[] controlArray = { "DropDownList","CheckBoxList","BulletedList","RadioButtonList","ListBox"}; Label1.Text = "String array created successfully!<br />Array elements:<br /><br /><i>"; foreach (string control in controlArray) { Label1.Text += control+ "<br />"; } Label1.Text += "</i>"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create string array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net array example: String Array</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Create String Array" ForeColor="DarkBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-create-string-array-in-aspnet_18.html
Example 2
How to get output of a string array using foreach loop in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[] myControls = {"CheckBoxList","TreeView","FormView","Gridview"}; Label1.Text = "Int array created successfully!"; Label2.Text = "Array Elements:<br /><br /><i>"; foreach (string element in myControls) { Label2.Text += element + "<br />"; } Label2.Text += "</i"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get output of a string array using foreach loop in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net array example:<br /> String Array and Foreach Loop</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="OrangeRed" Font-Bold="true" Font-Italic="false" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="IndianRed" Font-Bold="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server"
OnClick="Button1_Click" Font-Bold="true" Text="Create String Array and Get Output Using Foreach Loop" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-output-of-string-array-using_18.html
Example 3
How to get output of a string array using for loop in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[] controls = {"Button","CheckBox","RadioButton","RadioButtonList"}; Label1.Text = "String array created successfully!"; Label2.Text = "Array Elements: "; for (int i = 0; i < controls.Length; i++) { Label2.Text += controls[i] + " "; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get output of a string array using for loop in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net array example:<br /> String Array and For Loop</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="IndianRed" Font-Bold="true" Font-Italic="false" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Magenta" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1"
runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Create String Array and Get Output Using For Loop" ForeColor="Navy" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-output-of-string-array-using.html
Example 4
How to create two dimension string array in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[,] colorArray = { { "AliceBlue", "#F0F8FF" }, { "AntiqueWhite", "#FAEBD7" }, { "Aqua", "#00FFFF" }, { "Azure", "#F0FFFF" } }; Label1.Text = "Two dimensional String array created successfully!<br />Array elements:<br /><br /><i>"; int rows = colorArray.GetUpperBound(0); int columns = colorArray.GetUpperBound(1); Label2.Text = ""; for (int currentRow = 0; currentRow <= rows; currentRow++) { for (int currentColumn = 0; currentColumn <= columns; currentColumn++) { Label2.Text += colorArray[currentRow, currentColumn]; Label2.Text += " "; } Label2.Text += "<br />"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create two dimension string array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net array example: Two Dimension String Array</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server"
Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Create Two Dimensional String Array" ForeColor="DarkBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-create-two-dimension-string.html
Example 5
How to get output of a two dimension string array in asp.net
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[,] colors = { { "Beige", "#F5F5DC" }, { "Bisque", "#FFE4C4" }, { "BlueViolet", "#8A2BE2" }, { "Brown", "#A52A2A" }, { "BurlyWood", "#DEB887" } }; Label1.Text = "Two dimensional String array created successfully!<br />Output Of Array elements:<br /><br /><i>"; int rows = colors.GetUpperBound(0); int columns = colors.GetUpperBound(1); Label2.Text = ""; for (int currentRow = 0; currentRow <= rows; currentRow++) { for (int currentColumn = 0; currentColumn <= columns; currentColumn++) { Label2.Text += colors[currentRow, currentColumn]; Label2.Text += " "; } Label2.Text += "<br />"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get output of a two dimension string array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net array example:<br />Two Dimension String Array Output</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="OrangeRed" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large"
ForeColor="SaddleBrown" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Create Two Dimensional String Array And Show Output" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-output-of-two-dimension.html
Example 6
How to use GetUpperBound() method with two dimension string array in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[,] favoriteColors = { { "CadetBlue", "#5F9EA0" }, { "Chartreuse", "#7FFF00" }, { "Chocolate", "#D2691E" }, { "Coral", "#FF7F50" }, { "CornflowerBlue", "#6495ED" } }; Label1.Text = "Two dimensional String array created successfully!<br />Output Of Array elements:<br /><br /><i>"; int rows = favoriteColors.GetUpperBound(0); int columns = favoriteColors.GetUpperBound(1); Label2.Text = ""; for (int currentRow = 0; currentRow <= rows; currentRow++) { for (int currentColumn = 0; currentColumn <= columns; currentColumn++) { Label2.Text += favoriteColors[currentRow, currentColumn]; Label2.Text += " "; } Label2.Text += "<br />"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use GetUpperBound() method with two dimension string array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net array example:<br />Two Dimension String Array And GetUpperBound()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SlateBlue" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /> <asp:Label ID="Label2"
runat="server" Font-Size="Large" ForeColor="MediumVioletRed" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Create Two Dimensional String Array" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-use-getupperbound-method-with.html
Example 7
How to populate CheckBoxList from two dimension string array in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string[,] favoriteColors = { { "DarkSeaGreen", "#8FBC8F" }, { "DarkSlateBlue", "#483D8B" }, { "DarkSlateGray", "#2F4F4F" }, { "DarkTurquoise", "#00CED1" }, { "DarkViolet", "#9400D3" } }; Label1.Text = "Two dimensional String array created successfully!<br />and populates the CheckBoxList:<br /><br />"; int rows = favoriteColors.GetUpperBound(0); int columns = favoriteColors.GetUpperBound(1); CheckBoxList1.Items.Clear(); Label2.Text = ""; for (int currentRow = 0; currentRow <= rows; currentRow++) { ListItem li = new ListItem(); for (int currentColumn = 0; currentColumn <= columns; currentColumn++) { if (currentColumn == 0) { li.Text = favoriteColors[currentRow, currentColumn]; } else { li.Value = favoriteColors[currentRow, currentColumn]; } } CheckBoxList1.Items.Add(li); } } protected void Button2_Click(object sender, System.EventArgs e) { Label2.Text = "You selected:<br />"; foreach(ListItem li in CheckBoxList1.Items) { if(li.Selected == true) { Label2.Text += li.Text; Label2.Text += " [" + li.Value +"]<br />"; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">
<title>How to populate CheckBoxList from two dimension string array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net array example:<br />Two Dimension String Array And CheckBoxList</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="MediumSeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="DodgerBlue" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BackColor="Crimson" ForeColor="FloralWhite" RepeatColumns="3" BorderWidth="2" BorderColor="DarkRed" > </asp:CheckBoxList> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Populate CheckBoxList With Two Dimensional Array" ForeColor="DodgerBlue" /> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Font-Bold="true" Text="Show Selected Items" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-populate-checkboxlist-from-two.html
Example 8
How to get two dimension int array specific index position value in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> private int[,] numbers = {{100,150},{200,250},{300,350},{400,450},{500,550} }; protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Label1.Text = "Two dimensional Int array created successfully!<br />Array elements:<br /><br />"; int rows = numbers.GetUpperBound(0); int columns = numbers.GetUpperBound(1); for (int currentRow = 0; currentRow <= rows; currentRow++) { for (int currentColumn = 0; currentColumn <= columns; currentColumn++) { Label1.Text += numbers[currentRow, currentColumn]; Label1.Text += " "; } Label1.Text += "<br />"; } } } protected void Button1_Click(object sender, System.EventArgs e) { Label2.Text = "Array [1,1] Value: " + numbers[1, 1]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get two dimension int array specific index position value in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net array example:<br />Two Dimension Int Array Specific Index Value</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson" Font-Bold="true" Font-Italic="true"
> </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Magenta" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Get Array [1,1] Index Position Value" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-two-dimension-int-array.html
Example 9
How to get (search, find) array index position by array element value in asp.net(Array.IndexOf) <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> private string[] controls = { "SqlDataSource", "AccessDataSource", "ObjectDataSource", "XmlDataSource", "LinqDataSource", "EntityDataSource", "SiteMapDataSource" }; protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Label1.Text = "String array created successfully!<br />Array elements:<br /><br />"; foreach (string element in controls) { Label1.Text += element + "<br />"; } } } protected void Button1_Click(object sender, System.EventArgs e) { int indexOf = Array.IndexOf(controls, "LinqDataSource"); Label2.Text ="We Find [LinqDataSource] At the index position: " + indexOf.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get (search, find) array index position by array element value in asp.net(Array.IndexOf)</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net Array.IndexOf() example:<br />Search Array Index Number By Element Value</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large"
ForeColor="DodgerBlue" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Search Array [LinqDataSource] Index Position" ForeColor="SeaGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-search-find-array-index.html
Example 10
AccessKey example: how to use AccessKey in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>AccessKey example: how to use AccessKey in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Your <u>N</u>ame" AssociatedControlID="TextBox1" AccessKey="N"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label2" runat="server" Text="<u>C</u>ity Name" AssociatedControlID="TextBox2" AccessKey="C" /> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/accesskey-example-how-to-use-accesskey.html
Example 11
DataReader example: how to use DataReader in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { SqlConnection MyConnection; SqlCommand MyCommand; SqlDataReader MyReader; MyConnection = new SqlConnection(); MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString; MyCommand = new SqlCommand(); MyCommand.CommandText = "SELECT TOP 10 * From PRODUCTS"; MyCommand.CommandType = CommandType.Text; MyCommand.Connection = MyConnection; MyCommand.Connection.Open(); MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection); GridView1.DataSource = MyReader; GridView1.DataBind(); MyCommand.Dispose(); MyConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DataReader example: how to use DataReader in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/datareader-example-how-to-use.html
Example 12
DataAdapter example: how to use DataAdapter in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { SqlConnection MyConnection; SqlCommand MyCommand; SqlDataAdapter MyAdapter; DataTable MyTable; MyConnection = new SqlConnection(); MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString; MyCommand = new SqlCommand(); MyCommand.CommandText = "SELECT TOP 8 * FROM PRODUCTS"; MyCommand.CommandType = CommandType.Text; MyCommand.Connection = MyConnection; MyTable = new DataTable(); MyAdapter = new SqlDataAdapter(); MyAdapter.SelectCommand = MyCommand; MyAdapter.Fill(MyTable); GridView1.DataSource = MyTable.DefaultView; GridView1.DataBind(); MyAdapter.Dispose(); MyCommand.Dispose(); MyConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DataAdapter example: how to use DataAdapter in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server"></asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dataadapter-example-how-to-use.html
Example 13
SqlParameter example: how to use SqlParameter in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { SqlConnection MyConnection; SqlCommand MyCommand; SqlDataReader MyReader; SqlParameter ProductNameParam; MyConnection = new SqlConnection(); MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString; MyCommand = new SqlCommand(); MyCommand.CommandText = "SELECT * FROM PRODUCTS WHERE PRODUCTNAME = @PRODUCTNAME"; MyCommand.CommandType = CommandType.Text; MyCommand.Connection = MyConnection; ProductNameParam = new SqlParameter(); ProductNameParam.ParameterName = "@PRODUCTNAME"; ProductNameParam.SqlDbType = SqlDbType.VarChar; ProductNameParam.Size = 25; ProductNameParam.Direction = ParameterDirection.Input; ProductNameParam.Value = "CHAI"; MyCommand.Parameters.Add(ProductNameParam); MyCommand.Connection.Open(); MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection); GridView1.DataSource = MyReader; GridView1.DataBind(); MyCommand.Dispose(); MyConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>SqlParameter example: how to use SqlParameter in asp.net</title> </head> <body> <form id="form1" runat="server"> <div>
<asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/sqlparameter-example-how-to-use.html
Example 14
asp.net application state example: how to use application state in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int counter = 0; if(Application["ButtonClickCounter"] !=null) { counter = (int)Application["ButtonClickCounter"]; } counter++; Application["ButtonClickCounter"] = counter; Label1.Text = "Button Clicked: " + counter.ToString() + " times"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net application state example: how to use application state in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net application state example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"> </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Show Button Click Status" OnClick="Button1_Click" Font-Bold="true" ForeColor="SeaGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-application-state-example-how-to.html
Example 15
asp.net while loop example: while, do...while loop <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { int i = 0; while (i < 11) { i+=1; Label1.Text += i + ", "; } string[] Colors = { "DarkKhaki", "DarkOrchid", "DarkSalmon", "Pink" }; int ii =0; do { Label2.Text += Colors[ii] + " "; ii++; } while (ii < Colors.Length); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net while loop example: while, do...while loop</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">while loop example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkOrange"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Orchid"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-while-loop-example-while-dowhile.html
Example 16
asp.net SqlConnectionStringBuilder() example: how to build SqlConnectionString programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack) { SqlConnection myConnection = new SqlConnection(); SqlConnectionStringBuilder myBuilder = new SqlConnectionStringBuilder(); myBuilder.UserID = "sa"; myBuilder.Password = "mesa"; myBuilder.InitialCatalog = "Northwind"; myBuilder.DataSource = "localhost"; myBuilder.ConnectTimeout = 30; myConnection.ConnectionString = myBuilder.ConnectionString; myConnection.Open(); Label1.Text = "SqlConnection now : " + myConnection.State.ToString(); Label1.Text += "<br />DataBase : " + myConnection.Database.ToString(); myConnection.Close(); Label1.Text += "<br />SqlConnection now: " + myConnection.State.ToString(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlConnectionStringBuilder() example: how to build SqlConnectionString programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">SqlConnectionStringBuilder() Example</h2> <asp:Label ID="Label1" runat="server" ForeColor="Crimson" Font-Size="Large"> </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/how-to-build-sqlconnectionstring.html
Example 17
asp.net foreach loop example: using foreach loop with CheckBoxList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You selected: "; foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected == true) { Label1.Text += li + " "; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net foreach loop example: using foreach loop with CheckBoxList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">foreach loop example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="LightSlateGray"></asp:Label> <br /><br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" ForeColor="AntiqueWhite" BackColor="HotPink" BorderColor="Orange" BorderWidth="2" BorderStyle="Double" RepeatColumns="3" > <asp:ListItem>Aqua</asp:ListItem> <asp:ListItem>Aquamarine</asp:ListItem> <asp:ListItem>Bisque</asp:ListItem> <asp:ListItem>Blue</asp:ListItem> <asp:ListItem>BurlyWood</asp:ListItem> <asp:ListItem>Chocolate</asp:ListItem> <asp:ListItem>Coral</asp:ListItem> <asp:ListItem>Cyan</asp:ListItem> <asp:ListItem>DarkCyan</asp:ListItem> <asp:ListItem>DarkGreen</asp:ListItem> </asp:CheckBoxList> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit favorite" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-foreach-loop-example-using.html
Example 18
asp.net for loop example: using for loop <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { for (int i = 1; i < 11; i++) { Label1.Text += i + ", "; } string[] Colors = { "Red", "Pink", "Green", "Yellow", "Gray" }; for (int i = 0; i < Colors.Length; i++) { Label2.Text += Colors[i] + " "; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net for loop example: using for loop</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red"> for loop example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Teal"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-for-loop-example-using-for-loop.html
Example 19
asp.net switch statement example: switch, case, break, default <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { string li = RadioButtonList1.SelectedItem.Text; switch (li){ case ("LightSlateGray"): RadioButtonList1.BackColor = System.Drawing.Color.LightSlateGray; RadioButtonList1.ForeColor = System.Drawing.Color.White; RadioButtonList1.BorderColor = System.Drawing.Color.Gray; break; case ("SteelBlue"): RadioButtonList1.BackColor = System.Drawing.Color.SteelBlue; RadioButtonList1.ForeColor = System.Drawing.Color.LightYellow; RadioButtonList1.BorderColor = System.Drawing.Color.MediumBlue; break; default: RadioButtonList1.BackColor = System.Drawing.Color.Gold; RadioButtonList1.ForeColor = System.Drawing.Color.Magenta; RadioButtonList1.BorderColor = System.Drawing.Color.DarkOrange; break; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net switch statement example: switch, case, break, default</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">Switch Statement Example</h2> <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3" BorderWidth="2" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" BackColor="Gold" ForeColor="Magenta" BorderColor="DarkOrange" > <asp:ListItem>IndianRed</asp:ListItem> <asp:ListItem>LightSlateGray</asp:ListItem> <asp:ListItem>LightCoral</asp:ListItem>
<asp:ListItem>LightYellow</asp:ListItem> <asp:ListItem>LightSalmon</asp:ListItem> <asp:ListItem>Magenta</asp:ListItem> <asp:ListItem>SteelBlue</asp:ListItem> </asp:RadioButtonList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-switch-statement-example-switch.html
Example 20
asp.net if statement example: if(){} else if(){} else{} <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { string li = RadioButtonList1.SelectedItem.Text; if (li == "Pink") { RadioButtonList1.BackColor = System.Drawing.Color.HotPink; RadioButtonList1.ForeColor = System.Drawing.Color.AntiqueWhite; RadioButtonList1.BorderColor = System.Drawing.Color.LightPink; } else if (li == "Green") { RadioButtonList1.BackColor = System.Drawing.Color.SeaGreen; RadioButtonList1.ForeColor = System.Drawing.Color.AntiqueWhite; RadioButtonList1.BorderColor = System.Drawing.Color.LightGreen; } else { RadioButtonList1.BackColor = System.Drawing.Color.LightSeaGreen; RadioButtonList1.ForeColor = System.Drawing.Color.LightYellow; RadioButtonList1.BorderColor = System.Drawing.Color.DarkGreen; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net if statement example: if(){} else if(){} else{}</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">If Statement Example</h2> <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3" BorderWidth="1" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" BackColor="LightSeaGreen" ForeColor="LightYellow" BorderColor="DarkGreen" > <asp:ListItem>Red</asp:ListItem> <asp:ListItem>Blue</asp:ListItem> <asp:ListItem>Coral</asp:ListItem> <asp:ListItem>Green</asp:ListItem>
<asp:ListItem>DarkMagenta</asp:ListItem> <asp:ListItem>Pink</asp:ListItem> <asp:ListItem>Gold</asp:ListItem> </asp:RadioButtonList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-if-statement-example-if-else-if.html
Example 21
asp.net string manipulation example: Substring(), Insert(), Replace(), Remove() <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { string myString = "String Manipulation Example "; myString = myString.Trim(); Label1.Text = myString; myString = myString.ToUpper(); Label2.Text += "<br />ToUpper(): " + myString; myString = myString.ToLower(); Label2.Text += "<br />ToLower(): " + myString; myString = myString.Substring(0, 6); Label2.Text += "<br />Substring(0, 6) : " + myString; myString = myString.Insert(0, "my"); Label2.Text += "<br />Insert(0, \"my\") : " + myString; myString = myString.Replace("my", "new"); Label2.Text += "<br />Replace(\"my\", \"new\"): " + myString; myString = myString.Remove(0, 3); Label2.Text += "<br />Remove(0, 3) : " + myString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net string manipulation example: Substring(), Insert(), Replace(), Remove()</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">String Manipulation</h2> <hr /> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Teal"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="HotPink"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-string-manipulation-example.html
Example 22
asp.net Convert Class example: Convert.ToInt32(), Convert.ToString() <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { string numberString = "15"; int numberInt = Convert.ToInt32(numberString); numberInt *= 5; Label1.Text = "15*5 = " + numberInt.ToString(); int myNumber = 20; string myString = Convert.ToString(myNumber); myString = myString + " Years"; Label2.Text = myString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net Convert Class example: Convert.ToInt32(), Convert.ToString()</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">Convert Class example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="DarkMagenta"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Size="Larger" ForeColor="DarkMagenta"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-convert-class-example.html
Example 23
asp.net Math Class Example: Math.Sqrt(), Math.Round(), Math.Abs(), Math.Max(), Math.Min(), Math.Ceiling() <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { double myNumber; myNumber = Math.Sqrt(9); Label1.Text = "Math.Sqrt(9): " + myNumber + "<br/>"; myNumber = Math.Round(69.566, 2); Label1.Text += "<br/>Math.Round(69.566, 2): " + myNumber + "<br />"; myNumber = Math.Abs(9); Label1.Text += "<br/>Math.Abs(9) : " + myNumber + "<br />"; myNumber = Math.Max(13, 19); Label1.Text += "<br/>Math.Max(13, 19) : " + myNumber + "<br />"; myNumber = Math.Min(13, 19); Label1.Text += "<br/>Math.Min(13, 19) : " + myNumber + "<br />"; myNumber = Math.Ceiling(50.1); Label1.Text += "<br/>Math.Ceiling(50.1) : " + myNumber + "<br />"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net Math Class Example: Math.Sqrt(), Math.Round(), Math.Abs(), Math.Max(), Math.Min(), Math.Ceiling()</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">Math Class Example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="HotPink"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-math-class-example-mathsqrt.html
Example 24
asp.net ArrayList and BulletedList example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ ArrayList colorList = new ArrayList(); colorList.Add("RosyBrown"); colorList.Add("YellowGreen"); colorList.Add("Wheat"); colorList.Add("SlateGray"); colorList.Add("Red"); colorList.Add("Pink"); colorList.Add("Purple"); colorList.Sort(); BulletedList1.DataSource = colorList; BulletedList1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net ArrayList and BulletedList example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">ArrayList and BulletedList example</h2> <asp:Label ID="Label1" runat="server" Text="Sorted ColorList" ForeColor="DarkGreen" Font-Bold="true"> </asp:Label> <asp:BulletedList ID="BulletedList1" runat="server" BorderColor="Gray" BorderStyle="Double" BorderWidth="2" BackColor="DarkSlateGray" ForeColor="WhiteSmoke" Width="300" BulletStyle="Square" > </asp:BulletedList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-arraylist-and-bulletedlist.html
Example 25
asp.net HTML server control example: how to use HTML submit button as server control <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void SubmitButton_Click(object sender, System.EventArgs e) { Label1.Text = "Your favorite author is: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net HTML server control example: how to use HTML submit button as server control</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">HTML server control example: HTML submit button</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DodgerBlue" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" ForeColor="HotPink" Text="Your Favorte Author" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" ForeColor="Snow" BackColor="HotPink" > </asp:TextBox> <br /> <input runat="server" id="Button1" type="submit" value="Submit" onserverclick="SubmitButton_Click" /> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-html-server-control-example-how_09.html
Example 26
How to get web server installed font collection in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Text" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { InstalledFontCollection fontList = new InstalledFontCollection(); foreach(FontFamily family in fontList.Families) { ListBox1.Items.Add(family.Name); } } } protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Font.Name = ListBox1.SelectedItem.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to get web server installed font collection in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">Get Installed Font List</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Larger" Text="Hi Jones!" ForeColor="Crimson" > </asp:Label> <br /><br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="SeaGreen" ForeColor="FloralWhite" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" > </asp:ListBox> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2009/02/how-to-get-web-server-installed-font.html
Example 27
How to get color name list in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Text" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { string[] colorArray = Enum.GetNames(typeof(KnownColor)); ListBox1.DataSource = colorArray; ListBox1.DataBind(); } } protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.ForeColor = Color.FromName(ListBox1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get color name list in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">Get Color Name List</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Larger" Text="Hi Jenny!" ForeColor="Black" > </asp:Label> <br /><br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" > </asp:ListBox> </div> </form> </body>
</html> http://asp-net-example.blogspot.com/2009/02/how-to-get-color-name-list-in-aspnet.html
Example 28
How to get border style name list in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { string[] borderStyleArray = Enum.GetNames(typeof(BorderStyle)); ListBox1.DataSource = borderStyleArray; ListBox1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get border style name list in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">Get Border Style Name List</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Text="Border Style" ForeColor="DodgerBlue" > </asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" > </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/how-to-get-border-style-name-list-in.html
Example 29
How to create a color from ARGB value programmatically in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int alpha = Int32.Parse(TextBox1.Text); int red = Int32.Parse(TextBox2.Text); int green = Int32.Parse(TextBox3.Text); int blue = Int32.Parse(TextBox4.Text); Label1.ForeColor = Color.FromArgb(alpha, red, green, blue); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to create a color from ARGB value programmatically in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">Create Color From ARGB Value</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="XX-Large" Text="Dynamic Color" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Alpha" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DodgerBlue" ForeColor="FloralWhite" > </asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Font-Bold="true"
ForeColor="DodgerBlue" Text="Red" > </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="DodgerBlue" ForeColor="FloralWhite" > </asp:TextBox> <br /> <asp:Label ID="Label4" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Green" > </asp:Label> <asp:TextBox ID="TextBox3" runat="server" BackColor="DodgerBlue" ForeColor="FloralWhite" > </asp:TextBox> <br /> <asp:Label ID="Label5" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Blue" > </asp:Label> <asp:TextBox ID="TextBox4" runat="server" BackColor="DodgerBlue" ForeColor="FloralWhite" > </asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" Font-Bold="true" Text="Create Color and Change Label Color" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/how-to-create-color-from-argb-value.html
Example 30
How to change meta element in asp.net using the HtmlGenericControl class <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { Meta1.Attributes["name"] = "description"; Meta1.Attributes["content"] = "huge asp.net examples with images"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>How to change meta element in asp.net using the HtmlGenericControl class</title> <meta id="Meta1" runat="server" /> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">HtmlGenericControl Class Example: change meta element</h2> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/08/how-to-change-meta-element-in-aspnet.html
Example 31
asp.net caching example: how to use output caching <%@ Page Language="C#" %> <%@ OutputCache Duration="60" VaryByParam="None" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Label2.Text = "Present Time: "; Label2.Text += DateTime.Now.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net caching example: how to use output caching</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net example: Output Caching</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Text="Output Caching Duration: 60 seconds." > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="DodgerBlue" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-caching-example-how-to-use.html
Example 32
DataPager control - how to use DataPager control in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>DataPager control - how to use DataPager control in asp.net</title> <style type="text/css"> .TableCSS { border-style:none; background-color:OrangeRed; width: 600px; } .TableHeader { background-color:DeepPink; color:Snow; font-size:large; font-family:Verdana; height:45px; } .TableData { background-color:HotPink; color:Snow; font-family:Courier New; font-size:medium; font-weight:bold; height:30px; } .TablePager { background-color:DarkSeaGreen; height:50px; } .ButtonCSS { color:Green; height:35px; font-weight:bold; } .NumericButtonCSS { font-size:x-large; font-family:Courier New; color:Green; font-weight:bold; } .CurrentPageLabelCSS {
font-size:xx-large; font-family:Courier New; color:Green; font-weight:bold; } .NextPreviousButtonCSS { font-size:large; font-family:Courier New; color:Green; font-weight:bold; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">DataPager Control Example: How To Use DataPager Control</h2> <hr width="575" align="left" color="PowderBlue" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName From products Order By ProductID" > </asp:SqlDataSource> <br /> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" > <LayoutTemplate> <table id="Table1" runat="server" class="TableCSS"> <tr id="Tr1" runat="server" class="TableHeader"> <td id="Td1" runat="server">Product ID</td> <td id="Td2" runat="server">Product Name</td> </tr> <tr id="ItemPlaceholder" runat="server"> </tr> <tr id="Tr2" runat="server" class="TablePager"> <td id="Td3" runat="server" colspan="2"> <asp:DataPager ID="DataPager1" runat="server"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="true" ShowNextPageButton="true" ShowPreviousPageButton="false" ButtonCssClass="ButtonCSS" /> <asp:NumericPagerField NumericButtonCssClass="NumericButtonCSS" CurrentPageLabelCssClass="CurrentPageLabelCSS" NextPreviousButtonCssClass="NextPreviousButtonCSS" /> <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="true"
ShowNextPageButton="false" ButtonCssClass="ButtonCSS" /> </Fields> </asp:DataPager> </td> </tr> </table> </LayoutTemplate> <ItemTemplate> <tr class="TableData"> <td> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductID")%>' > </asp:Label> </td> <td> <asp:Label ID="Label2" runat="server" Text='<%# Eval("ProductName")%>' > </asp:Label> </td> </tr> </ItemTemplate> </asp:ListView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/12/datapager-control-how-to-use-datapager.html
Example 33
asp.net FormView example: how to use ItemTemplate and Paging <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net FormView example: how to use ItemTemplate and Paging</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">Example: FormView</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PubsConnectionString %>" SelectCommand="SELECT emp_id, fname, lname, hire_date FROM employee" > </asp:SqlDataSource> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="emp_id" AllowPaging="true" > <HeaderTemplate> Employee Details </HeaderTemplate> <HeaderStyle BackColor="DarkBlue" ForeColor="AliceBlue" BorderColor="DarkOrange" BorderStyle="None" BorderWidth="2" Font-Size="Medium" Font-Italic="false" Font-Bold="true" Height="35" HorizontalAlign="Center" /> <ItemTemplate> <b>Employee ID:</b> <i><%# Eval("emp_id") %></i> <br /> <b>Employee Name:</b> <i><%# Eval("lname") %> <%# Eval("fname") %></i> <br /> <b>Hire Date:</b> <i><%# Eval("hire_date") %></i> </ItemTemplate>
<RowStyle BackColor="DodgerBlue" ForeColor="AliceBlue" /> <PagerSettings Mode="NumericFirstLast" FirstPageText="First" LastPageText="Last" /> <PagerStyle BackColor="DarkBlue" ForeColor="AliceBlue" /> </asp:FormView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-formview-example-how-to-use.html
Example 34
ListView control - how to use ListView control in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>ListView control - how to use ListView control in asp.net</title> <style type="text/css"> .TableCSS { border-style:none; background-color:DarkOrange; width: 600px; } .TableHeader { background-color:OrangeRed; color:Snow; font-size:large; font-family:Verdana; } .TableData { background-color:Orange; color:Snow; font-family:Courier New; font-size:medium; font-weight:bold; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">ListView Control Example: How To Use ListView Control</h2> <hr width="550" align="left" color="PowderBlue" /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName From products Order By ProductID" > </asp:SqlDataSource> <br /> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" >
<LayoutTemplate> <table runat="server" class="TableCSS"> <tr runat="server" class="TableHeader"> <td runat="server">Product ID</td> <td runat="server">Product Name</td> </tr> <tr id="ItemPlaceholder" runat="server"> </tr> <tr runat="server"> <td runat="server" colspan="2"> <asp:DataPager ID="DataPager1" runat="server"> <Fields> <asp:NextPreviousPagerField ButtonType="Link" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Link" /> </Fields> </asp:DataPager> </td> </tr> </table> </LayoutTemplate> <ItemTemplate> <tr class="TableData"> <td> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductID")%>' > </asp:Label> </td> <td> <asp:Label ID="Label2" runat="server" Text='<%# Eval("ProductName")%>' > </asp:Label> </td> </tr> </ItemTemplate> </asp:ListView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/12/listview-control-how-to-use-listview.html
Example 35
ListView ItemTemplate and AlternatingItemTemplate - how to use <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>ListView ItemTemplate and AlternatingItemTemplate - how to use</title> <style type="text/css"> .TableCSS { border-style:none; background-color:IndianRed; width: 700px; } .TableHeader { background-color:Crimson; color:Snow; font-size:large; font-family:Verdana; height:45px; text-align:center; } .ItemCSS { background-color:IndianRed; color:Snow; font-family:MS Sans Serif; font-size:medium; font-weight:bold; height:28px; } .AlternatingItemCSS { background-color:Salmon; color:Snow; font-family:MS Sans Serif; font-size:medium; font-weight:bold; height:28px; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OliveDrab; font-style:italic;"> ListView Example: How To Use <br /> ItemTemplate And AlternatingItemTemplate </h2> <hr width="575" align="left" color="Salmon" />
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select Top 10 ProductName, UnitPrice, QuantityPerUnit From products Order By ProductName" > </asp:SqlDataSource> <br /> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" > <LayoutTemplate> <table runat="server" class="TableCSS"> <tr runat="server" class="TableHeader"> <td runat="server">Product Name</td> <td runat="server">Unit Price</td> <td runat="server">Quantity Per Unit</td> </tr> <tr id="ItemPlaceholder" runat="server"> </tr> </table> </LayoutTemplate> <ItemTemplate> <tr class="ItemCSS"> <td> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName")%>' > </asp:Label> </td> <td> <asp:Label ID="Label2" runat="server" Text='<%# Eval("UnitPrice")%>' > </asp:Label> </td> <td> <asp:Label ID="Label3" runat="server" Text='<%# Eval("QuantityPerUnit")%>' > </asp:Label> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr class="AlternatingItemCSS"> <td> <asp:Label ID="Label1" runat="server" Text='<%# Eval("ProductName")%>' > </asp:Label> </td>
<td> <asp:Label ID="Label2" runat="server" Text='<%# Eval("UnitPrice")%>' > </asp:Label> </td> <td> <asp:Label ID="Label3" runat="server" Text='<%# Eval("QuantityPerUnit")%>' > </asp:Label> </td> </tr> </AlternatingItemTemplate> </asp:ListView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/12/listview-itemtemplate-and.html
Example 36
Literal example: how to use Mode Encode, PassThrough, Transform <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Literal example: how to use Mode Encode, PassThrough, Transform</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Literal ID="Literal1" runat="server" Mode="Encode" Text="<b><u>Literal web server control: Mode Encode</u></b>" > </asp:Literal> <br /> <asp:Literal ID="Literal2" runat="server" Mode="PassThrough" Text="<b><u>Literal web server control: Mode PassThrough</u></b>" > </asp:Literal> <br /> <asp:Literal ID="Literal3" runat="server" Mode="Transform" Text="<b><u>Literal web server control: Mode Transform</u></b>" > </asp:Literal> <br /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/literal-example-how-to-use-mode-encode.html
Example 37
MultiView example: how to use MultiView control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ MultiView1.ActiveViewIndex = 0; } } void NextImage(object sender, System.EventArgs e) { MultiView1.ActiveViewIndex += 1; } protected void Page_PreRender(object sender, System.EventArgs e) { Label1.Text = "Beautiful Forest Image: " + (MultiView1.ActiveViewIndex + 1).ToString() + " of " + MultiView1.Views.Count.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>MultiView Control Simple Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /><br /> <asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="View1" runat="server"> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Forest1.jpg" /> <br /> <asp:Button ID="Button1" runat="server" Text="Next Image" OnClick="NextImage" /> </asp:View> <asp:View ID="View2" runat="server"> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/Forest2.jpg" /> <br /> <asp:Button ID="Button2" runat="server" Text="Next Image" OnClick="NextImage" /> </asp:View> <asp:View ID="View3" runat="server"> <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Forest3.jpg" /> <br /> <asp:Button ID="Button3" runat="server" Text="Next Image" OnClick="NextImage" /> </asp:View> <asp:View ID="View4" runat="server">
<asp:Image ID="Image4" runat="server" ImageUrl="~/Images/Forest4.jpg" /> <br /> <asp:Button ID="Button4" runat="server" Text="Next Image" OnClick="NextImage" /> </asp:View> <asp:View ID="View5" runat="server"> <asp:Image ID="Image5" runat="server" ImageUrl="~/Images/Forest5.jpg" /> </asp:View> </asp:MultiView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/multiview-example-how-to-use-multiview.html
Example 38
asp.net Substitution and Caching example: how to use Substitution Control <%@ Page Language="C#" %> <!-<%@ OutputCache Duration="300" VaryByParam="none" %>--> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> static string myRandomNumber(HttpContext context) { int myNumber = new System.Random().Next(100, 500); return myNumber.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net Substitution and Caching example: how to use Substitution Control</title> </head> <body> <form id="form1" runat="server"> <div> <h1 style="color:Fuchsia">Substitution Example</h1> <asp:Label ID="Label1" runat="server"></asp:Label> Page Cached Time: <h2 style="color:Teal"> <%= DateTime.Now.ToLongTimeString() %> </h2> Current Time: <h2 style="color:Navy"> <%= DateTime.Now.ToLongTimeString() %> </h2> <hr /> Substitition Control Zone [Random Number] <h1 style="color:Red"> <asp:Substitution ID="Substitution1" runat="server" MethodName="myRandomNumber" /> </h1> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-substitution-and-caching-example.html
Example 39
asp.net ViewState example: how to use ViewState in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int clickCounter = 1; if (ViewState["ClickCounter"] == null) { clickCounter = 1; } else { clickCounter = (int)ViewState["ClickCounter"] + 1; } ViewState["ClickCounter"] = clickCounter; Label1.Text = "Button clicked " + clickCounter + " times."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net ViewState example: how to use ViewState in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net ViewState example</h2> <asp:Label ID="Label1" runat="server" ForeColor="DarkGreen" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" ForeColor="HotPink" Font-Bold="true" Text="Show Button Click Status" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-viewstate-example-how-to-use.html
Example 40
How to use BulletedList display mode (DisplayMode) as LinkButton <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void BulletedList1_Click(object sender, System.Web.UI.WebControls.BulletedListEventArgs e) { Label1.Text = "You Choose: " + BulletedList1.Items[e.Index].Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use BulletedList display mode (DisplayMode) as LinkButton</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">BulletedList: DisplayMode LinkButton</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Crimson" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="asp.net controls" > </asp:Label> <asp:BulletedList ID="BulletedList1" runat="server" Width="275" BorderColor="DarkBlue" BorderWidth="2" DisplayMode="LinkButton" OnClick="BulletedList1_Click" > <asp:ListItem>ListView</asp:ListItem> <asp:ListItem>FormView</asp:ListItem> <asp:ListItem>LinqDataSource</asp:ListItem> <asp:ListItem>XmlDataSource</asp:ListItem> <asp:ListItem>RegularExpressionValidator</asp:ListItem> </asp:BulletedList>
</div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-bulletedlist-display-mode_23.html
Example 41
How to remove list item by item text in BulletedList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string itemText = TextBox1.Text.ToString(); if (BulletedList1.Items.FindByText(itemText) != null) { Label1.Text = "Item Found and remove: " + itemText; BulletedList1.Items.Remove(itemText); } else { Label1.Text = "Item not Found: " + itemText; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to remove list item by item text in BulletedList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">BulletedList example: Remove List Item</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Green" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="asp.net controls" Font-Bold="true" ForeColor="DarkBlue" > </asp:Label> <br /> <asp:BulletedList ID="BulletedList1" runat="server" BackColor="DarkBlue" ForeColor="Snow" Width="280" >
<asp:ListItem>LinqDataSource</asp:ListItem> <asp:ListItem>ImageMap</asp:ListItem> <asp:ListItem>Literal</asp:ListItem> <asp:ListItem>Panel</asp:ListItem> <asp:ListItem>XmlDataSource</asp:ListItem> </asp:BulletedList> <br /><br /> <asp:Label ID="Label3" runat="server" ForeColor="DarkBlue" Text="Item Text" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkBlue" ForeColor="Snow" > </asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Remove List Item" Font-Bold="true" ForeColor="DarkBlue" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-remove-list-item-by-item-text-in_18.html
Example 42
asp.net Button example: how to use OnClientClick event <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button2_Click(object sender, System.EventArgs e) { Label1.Text = "Button2 Clicked!"; } </script> <script type="text/javascript"> function AlertOnClientClick() { alert('OnClientClick event triggered!'); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net Button example: how to use OnClientClick event</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Purple">Using OnClientClick event</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGreen"></asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Click Me" OnClientClick="AlertOnClientClick()" Font-Bold="true" ForeColor="Teal" /> <asp:Button ID="Button2" runat="server" Text="Button2" OnClick="Button2_Click" Font-Bold="true" ForeColor="Teal" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-button-example-how-to-use.html
Example 43
asp.net Button example: how to use OnCommand and CommandName property <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button_Command(Object sender, System.Web.UI.WebControls.CommandEventArgs e) { switch(e.CommandName) { case ("CheckedNow"): CheckBox1.Checked = true; break; case ("UnCheckedNow"): CheckBox1.Checked = false; break; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net Button example: how to use OnCommand and CommandName property</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Fuchsia">Using CommandName property</h2> <asp:CheckBox ID="CheckBox1" runat="server" Text="Click the button for checked or unchecked" ForeColor="Red" /> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Check Now" OnCommand="Button_Command" CommandName="CheckedNow" Font-Bold="true" ForeColor="Teal" /> <asp:Button ID="Button2" runat="server" Text="UnCheck Now" OnCommand="Button_Command" CommandName="UnCheckedNow" Font-Bold="true" ForeColor="Teal" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-button-example-how-to-use.html
Example 44
How to set, change Calendar style programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Calendar1.BackColor = Color.PaleVioletRed; Calendar1.ForeColor = Color.AliceBlue; Calendar1.BorderColor = Color.DarkRed; Calendar1.TitleStyle.BackColor = Color.DarkOrange; Calendar1.DayHeaderStyle.BackColor = Color.DarkSalmon; Calendar1.OtherMonthDayStyle.BackColor = Color.SaddleBrown; Calendar1.TitleStyle.Font.Bold = true; Calendar1.OtherMonthDayStyle.Font.Italic = true; Calendar1.TodayDayStyle.BackColor = Color.Crimson; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to set, change Calendar style programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">Calendar Example: Change Style</h2> <asp:Calendar ID="Calendar1" runat="server" > </asp:Calendar> <br /> <asp:Button ID="Button1" runat="server" ForeColor="SaddleBrown" Text="Change Calendar Style" Height="45" OnClick="Button1_Click" Font-Bold="true" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/04/how-to-set-change-calendar-style.html
Example 45
asp.net Chart example: how to use Chart in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net Chart example: how to use Chart in asp.net</title> <style type="text/css"> h2 { color:Crimson; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2>Chart example and tutorial: How to use Chart in asp.net</h2> <hr width="550" align="left" color="SandyBrown" /> <br /> <asp:Chart ID="Chart1" runat="server" BackColor="Ivory"> <Series> <asp:Series Name="Salary" YValueType="Int32" ChartType="FastLine" ChartArea="DefaultChartArea" > <Points> <asp:DataPoint AxisLabel="Ben" YValues="45000" /> <asp:DataPoint AxisLabel="Loren" YValues="35000" /> <asp:DataPoint AxisLabel="Anne" YValues="10000" /> <asp:DataPoint AxisLabel="Suma" YValues="7500" /> <asp:DataPoint AxisLabel="Suria" YValues="7500" /> </Points> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="DefaultChartArea"> </asp:ChartArea> </ChartAreas> </asp:Chart> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2010/09/aspnet-chart-example-how-to-use-chart.html
Example 46
How to use Chart BackHatchStyle in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Chart1.BackHatchStyle = ChartHatchStyle.Percent10; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use Chart BackHatchStyle in asp.net</title> <style type="text/css"> h2 { color:DodgerBlue; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2>How to use Chart BackHatchStyle in asp.net</h2> <hr width="470" align="left" color="LightBlue" /> <br /> <asp:Chart ID="Chart1" runat="server" BackColor="Green" BackHatchStyle="Cross"> <Titles> <asp:Title Text="Sample chart of salary" BackColor="SeaGreen" ForeColor="Snow" BorderColor="LawnGreen" Font="Comic Sans MS" BorderDashStyle="DashDot" BorderWidth="1" > </asp:Title> </Titles> <Series> <asp:Series Name="Salary" YValueType="Int32" ChartType="Area" ChartArea="DefaultChartArea" Color="SaddleBrown" > <Points> <asp:DataPoint AxisLabel="Mintu" YValues="24300" /> <asp:DataPoint Color="Red" AxisLabel="Sakil"
YValues="24795" /> <asp:DataPoint AxisLabel="Sattar" YValues="21050" /> <asp:DataPoint Color="Orange" AxisLabel="Popy" YValues="32700" /> <asp:DataPoint AxisLabel="Sohag" YValues="27500" /> </Points> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="DefaultChartArea" BackColor="LavenderBlush" Area3DStyle-Enable3D="true"> </asp:ChartArea> </ChartAreas> </asp:Chart> <br /> <asp:Button ID="Button1" runat="server" Text="Set Chart BackHatchStyle Percent10" Font-Bold="true" OnClick="Button1_Click" Font-Names="Comic Sans MS" ForeColor="DarkBlue" Height="45" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2010/09/how-to-use-chart-backhatchstyle-in.html
Example 47
How to create 3-D Chart in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <%@Import Namespace="System.Web.UI.DataVisualization.Charting" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create 3-D Chart in asp.net</title> <style type="text/css"> h2 { color:DarkBlue; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2>Chart example and tutorial: How to create<br />3-D Chart in asp.net</h2> <hr width="525" align="left" color="AliceBlue" /> <br /> <asp:Chart ID="Chart1" runat="server" BackColor="Pink" Width="525" > <Series> <asp:Series Name="AnnualSalary" YValueType="Int32" ChartArea="ChartArea1" Color="OrangeRed" ChartType="Bar" > <Points> <asp:DataPoint AxisLabel="Maliha" YValues="36600" /> <asp:DataPoint AxisLabel="Moli" YValues="17500" /> <asp:DataPoint AxisLabel="Samim" YValues="48400" /> <asp:DataPoint AxisLabel="Sammi" YValues="19300" /> </Points> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="ChartArea1" BackColor="Snow"
BorderColor="SaddleBrown" BorderWidth="2" BorderDashStyle="Dash" > <Area3DStyle Enable3D="true" Perspective="8" IsRightAngleAxes="False" Inclination="15" WallWidth="0" IsClustered="False" /> <AxisX> <MajorGrid LineColor="RosyBrown" /> <LabelStyle ForeColor="IndianRed" /> </AxisX> <AxisY> <MajorGrid LineColor="RosyBrown" /> <LabelStyle ForeColor="IndianRed" /> </AxisY> </asp:ChartArea> </ChartAreas> </asp:Chart> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2010/09/how-to-create-3-d-chart-in-aspnet.html
Example 48
How to create Chart PaletteCustomColors (Custom Palette) in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Chart1.Palette = ChartColorPalette.None; Chart1.PaletteCustomColors = new Color[] { Color.Crimson, Color.DarkSeaGreen, Color.CornflowerBlue, Color.DeepPink, Color.Pink }; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create Chart PaletteCustomColors (Custom Palette) in asp.net</title> <style type="text/css"> h2 { color:SaddleBrown; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2>Chart example and tutorial: How to create<br /> Chart PaletteCustomColors in asp.net</h2> <hr width="450" align="left" color="RosyBrown" /> <br /> <asp:Chart ID="Chart1" runat="server" > <Legends> <asp:Legend Name="ChartLegend" Docking="Bottom" Alignment="Center" > </asp:Legend> </Legends> <Series> <asp:Series Name="Salary" YValueType="Int32" ChartType="Pie" ChartArea="DefaultChartArea" > <Points>
<asp:DataPoint AxisLabel="Sagor" YValues="7300" /> <asp:DataPoint AxisLabel="Sonali" YValues="22695" /> <asp:DataPoint AxisLabel="Rani" YValues="19250" /> <asp:DataPoint AxisLabel="Popy" YValues="9750" /> <asp:DataPoint AxisLabel="Sophia" YValues="36500" /> </Points> </asp:Series> </Series> <ChartAreas> <asp:ChartArea Name="DefaultChartArea" Area3DStyle-Enable3D="true" > </asp:ChartArea> </ChartAreas> </asp:Chart> <br /> <asp:Button ID="Button1" runat="server" Text="Set Chart Custom Palette" Font-Bold="true" OnClick="Button1_Click" ForeColor="SaddleBrown" Height="45" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2010/09/how-to-create-chart-palettecustomcolors.html
Example 49
CheckBox example: how to use CheckBox control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-/W3C//DTD/ XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1-transitional.dtd"> <script runat="server"> protected void CheckBox1_CheckChanged(object sender, System.EventArgs e) { Response.Write("Membership status: "); if (CheckBox1.Checked == true) { Label1.Text = "Member"; CheckBox2.Checked = true; } else{ Label1.Text = "Not a Member"; CheckBox2.Checked = false; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CheckBox example: how to use CheckBox control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server"></asp:Label> <hr /> <asp:CheckBox ID="CheckBox1" runat="server" Text="Are you asp.net user group member?" OnCheckedChanged="CheckBox1_CheckChanged" AutoPostBack="true" /> <br /> <asp:CheckBox ID="CheckBox2" runat="Server" Text="Check Box auto checked depend on another checkbox" TextAlign="Left" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/checkbox-example-how-to-use-checkbox.html
Example 50
CheckBoxList control example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You selected :<br />"; foreach(ListItem li in CheckBoxList1.Items){ if (li.Selected == true) { Label1.Text += li.Text + "<br />"; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CheckBoxList control simple example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Select favorites" AssociatedControlID="CheckBoxList1"></asp:Label> <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:ListItem>ColdFusion</asp:ListItem> <asp:ListItem>PHP</asp:ListItem> <asp:ListItem>JSP</asp:ListItem> <asp:ListItem>Asp.Net</asp:ListItem> <asp:ListItem>Flex</asp:ListItem> </asp:CheckBoxList> <br /> <asp:Button ID="Button1" runat="server" Text="Show Result" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/checkboxlist-control-example.html
Example 51
asp.net CheckBoxList Items.RemoveAt() example: how to remove item by index number <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int indexNumber = Convert.ToInt32(TextBox1.Text); CheckBoxList1.Items.RemoveAt(indexNumber); Label1.Text = "Item removed from index number: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net CheckBoxList Items.RemoveAt() example: how to remove item by index number</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">CheckBoxList Items.RemoveAt() example</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Crimson"></asp:Label> <br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server"> <asp:ListItem>HoneyDew</asp:ListItem> <asp:ListItem>HotPink</asp:ListItem> <asp:ListItem>IndianRed </asp:ListItem> <asp:ListItem>Indigo</asp:ListItem> <asp:ListItem>Ivory</asp:ListItem> <asp:ListItem>Khaki</asp:ListItem> </asp:CheckBoxList> <br /><br /> <b style="color:Navy">Index start from 0</b> <br /> <asp:Label ID="Label2" runat="server" Text="Position[Index]" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox1" Operator="DataTypeCheck" Type="Integer" ErrorMessage="Input valid number!"></asp:CompareValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Remove Item" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-checkboxlist-itemsremoveat.html
Example 52
asp.net CheckBoxList Items.FindByText() method example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { CheckBoxList1.Items.FindByText(TextBox1.Text).Selected = true; Label1.Text = "CheckBoxList Item selected."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net CheckBoxList Items.FindByText() method example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">CheckBoxList Items.FindByText() Example</h2> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large"></asp:Label> <br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BackColor="AliceBlue" ForeColor="CornflowerBlue"> <asp:ListItem>Tomato</asp:ListItem> <asp:ListItem>Turquoise</asp:ListItem> <asp:ListItem>Violet</asp:ListItem> </asp:CheckBoxList> <hr /> <asp:Label ID="Label2" runat="server" Text="CheckBoxList Item Text" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="AliceBlue" ForeColor="RoyalBlue"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text=" Select CheckBoxList Item" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-checkboxlist-itemsfindbytext.html
Example 53
asp.net CheckBoxList Items.FindByValue() method example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { CheckBoxList1.Items.FindByValue(TextBox1.Text).Selected = true; Label1.Text = "CheckBoxList Item selected."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net CheckBoxList Items.FindByValue() method example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">CheckBoxList Items.FindByValue() Example</h2> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large"></asp:Label> <br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BackColor="AliceBlue" ForeColor="Navy" RepeatColumns="2"> <asp:ListItem Value="#F5DEB3">Wheat</asp:ListItem> <asp:ListItem Value="#FFFFFF">White</asp:ListItem> <asp:ListItem Value="#F5F5F5">WhiteSmoke</asp:ListItem> <asp:ListItem Value="#FFFF00">Yellow</asp:ListItem> <asp:ListItem Value="#9ACD32">YellowGreen</asp:ListItem> </asp:CheckBoxList> <hr /> <asp:Label ID="Label2" runat="server" Text="CheckBoxList Item Value" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="AliceBlue" ForeColor="RoyalBlue"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text=" Select CheckBoxList Item" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-checkboxlist-itemsfindbyvalue.html
Example 54
How to use OnSelectedIndexChanged event in CheckBoxList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void CheckBoxList1_SelectedIndexChnaged(object sender, System.EventArgs e) { Label1.Text = "You Choose Color:<br /><i>"; foreach (ListItem li in CheckBoxList1.Items) { if (li.Selected == true) { Label1.Text += li.Text + "<br />"; } } Label1.Text += "</i>"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use OnSelectedIndexChanged event in CheckBoxList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">CheckBoxList: OnSelectedIndexChanged</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Crimson" Font-Size="Large" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="DarkBlue" Text="Color List" > </asp:Label> <asp:CheckBoxList ID="CheckBoxList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="CheckBoxList1_SelectedIndexChnaged" BackColor="DodgerBlue" ForeColor="FloralWhite" >
<asp:ListItem>AntiqueWhite</asp:ListItem> <asp:ListItem>Ivory</asp:ListItem> <asp:ListItem>DarkViolet</asp:ListItem> <asp:ListItem>Lavender</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> </asp:CheckBoxList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-onselectedindexchanged-event.html
Example 55
CompareValidator example: how to use CompareValidator control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender,System.EventArgs e){ Label1.Text = "Form Submited and Password match."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>CompareValidator example: how to use CompareValidator control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="<u>P</u>assword" AccessKey="P" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" TextMode="Password"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <asp:CompareValidator ID="CompareValidator" runat="server" ControlToValidate="TextBox1" ControlToCompare="TextBox2" ErrorMessage="Password does not match!"> </asp:CompareValidator> <br /> <asp:Label ID="Label3" runat="server" Text="Re-Type Password" AssociatedControlID="TextBox2"></asp:Label> <asp:TextBox ID="TextBox2" runat="server" TextMode="Password"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Compare" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/comparevalidator-example-how-to-use.html
Example 56
CompareValidator example: how to validate Data Type in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Transitional/EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender,System.EventArgs e){ Label1.Text = "Form Submited. Your value is Integer"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>CompareValidator example: how to validate Data Type in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="DarkCyan"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Age" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <asp:CompareValidator ID="CompareFieldValidator1" runat="server" ControlToValidate="TextBox1" Operator="DataTypeCheck" Type="Integer" ErrorMessage="Input valid age"> </asp:CompareValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Validate DataType" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/comparevalidator-example-how-to.html
Example 57
asp.net ControlParameter example: how to use ControlParameter <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net ControlParameter example: how to use ControlParameter</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">ControlParameter Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT CategoryID, CategoryName FROM Categories"> </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID=@CategoryID"> <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" Name="CategoryID" PropertyName="SelectedValue" /> </SelectParameters> </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Text="Category" AssociatedControlID="DropDownList1" ForeColor="Green"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" AutoPostBack="true" > </asp:DropDownList> <br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" ForeColor="SlateGray" BackColor="Snow" BorderColor="HotPink"> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-controlparameter-example-how-to.html
Example 58
asp.net cookie example: how to use cookie in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Net" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { HttpCookie favoriteColor = Request.Cookies["FavoriteColor"]; if (favoriteColor == null) { HttpCookie userCookie = new HttpCookie("FavoriteColor"); userCookie["Name"] = "Jones"; userCookie["Color"] = "Crimson"; userCookie.Expires = DateTime.Now.AddDays(1); Response.Cookies.Add(userCookie); Label1.Text = "Cookie created at: " + DateTime.Now.ToString()+ "<br /><br />"; } else { string name = favoriteColor["Name"]; string color = favoriteColor["Color"]; Label1.Text += "Cookie found and read<br />"; Label1.Text += "Hi " + name + " your favorite Color: " + color; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net cookie example: how to use cookie in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net cookie: how to use</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen"> </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-cookie-example-how-to-use-cookie.html
Example 59
asp.net cookie example: how to read a cookie <%@ Page Language="C#" %> <%@ Import Namespace="System.Net" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { HttpCookie infoCookie = new HttpCookie("Info"); infoCookie["Country"] = "USA"; infoCookie["City"] = "NewYork"; infoCookie["Name"] = "Jenny"; infoCookie.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(infoCookie); } } protected void Button1_Click(object sender, System.EventArgs e) { HttpCookie cookie = Request.Cookies["Info"]; if (cookie != null) { string country = cookie["Country"]; string city = cookie["City"]; string name = cookie["Name"]; Label1.Text = "Cookie[Info] Found and read<br/>"; Label1.Text += "Name: " + name; Label1.Text += "<br />Country: " + country; Label1.Text += "<br />City: " + city; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net cookie example: how to read a cookie</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net Cookie example: Read a cookie</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGreen"> </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server"
Text="Read Cookie" OnClick="Button1_Click" Font-Bold="true" ForeColor="HotPink" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-cookie-example-how-to-read.html
Example 60
asp.net cookie example: how to set value in a cookie <%@ Page Language="C#" %> <%@ Import Namespace="System.Net" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { HttpCookie testCokkie = new HttpCookie("ExampleCookie"); testCokkie.Expires = DateTime.Now.AddDays(5); Response.Cookies.Add(testCokkie); } } protected void Button1_Click(object sender, System.EventArgs e) { HttpCookie ExampleCookie = Request.Cookies["ExampleCookie"]; ExampleCookie["Name"] = TextBox1.Text.ToString(); ExampleCookie["City"] = TextBox2.Text.ToString(); Response.Cookies.Add(ExampleCookie); } protected void Button2_Click(object sender, System.EventArgs e) { HttpCookie exampleCookie = Request.Cookies["ExampleCookie"]; if (exampleCookie != null) { string name = exampleCookie["Name"]; string city = exampleCookie["City"]; label1.Text = "Cookie found and read<br />"; label1.Text += "Name: " + name + "<br />City: " + city; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net cookie example: how to set value in a cookie</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net cookie example: set value</h2> <asp:Label ID="label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Name"> </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="LightGreen">
</asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Text="City"> </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="LightGreen"> </asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Set cookie value" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> <asp:Button ID="Button2" runat="server" Text="Read cookie" OnClick="Button2_Click" Font-Bold="true" ForeColor="DarkGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-cookie-example-how-to-set-value.html
Example 61
asp.net date time example: how to subtract between two date time object <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { DateTime firstDateTime = DateTime.Now; DateTime secondDateTime = DateTime.Now.AddDays(3); TimeSpan dateTimeDifference; dateTimeDifference = secondDateTime.Subtract(firstDateTime); double totalHours = dateTimeDifference.TotalHours; Label1.Text = "FirstDateTime: " + firstDateTime.ToString(); Label1.Text += "<br />SecondDateTime: " + secondDateTime.ToString(); Label1.Text += "<br /><br />Total Hours Difference Between Two DateTime Object: " + totalHours; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net date time example: how to subtract between two date time object</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net date time example: subtract date time</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" Font-Italic="true" Font-Bold="true" ForeColor="DodgerBlue" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="DarkBlue" OnClick="Button1_Click" Text="Subtract Two DateTime Object" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-date-time-example-how-to.html
Example 62
asp.net date time example: how to use TimeSpan (time span) in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { DateTime myDateTime1 = DateTime.Now; DateTime myDateTime2 = DateTime.Now.AddMinutes(15); TimeSpan dateTimeDifference; dateTimeDifference = myDateTime2.Subtract(myDateTime1); double numberOfSeconds = dateTimeDifference.TotalSeconds; Label1.Text = "FirstDateTime: " + myDateTime1.ToString(); Label1.Text += "<br />SecondDateTime: " + myDateTime2.ToString(); Label1.Text += "<br /><br />Total Seconds Difference Between Two DateTime Object: " + numberOfSeconds; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net date time example: how to use TimeSpan (time span) in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net date time example: TimeSpan</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" Font-Italic="true" Font-Bold="true" ForeColor="MediumVioletRed" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="MediumVioletRed" OnClick="Button1_Click" Text="Get Total Seconds Difference" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-date-time-example-how-to-use.html
Example 63
asp.net DetailsView example: how to use DetailsView <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net DetailsView example: how to use DetailsView</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">DetailsView Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products"> </asp:SqlDataSource> <asp:DetailsView ID="DetailsView" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" ForeColor="DarkGreen" BackColor="Snow" BorderColor="Tomato"> </asp:DetailsView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-detailsview-example-how-to-use.html
Example 64
asp.net asp:CheckBoxField example: how to use CheckBoxField in DetailsView <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net asp:CheckBoxField example: how to use CheckBoxField in DetailsView</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">DetailsView CheckBoxField Example</h2> <asp:Label ID="Label1" runat="server" Font-Italic="true" ForeColor="Red"></asp:Label> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice, Discontinued FROM Products" > </asp:SqlDataSource> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" ForeColor="AliceBlue" BackColor="DodgerBlue" BorderColor="LightSkyBlue" AutoGenerateRows="false" > <Fields> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice" /> <asp:CheckBoxField HeaderText="Discontinued" DataField="Discontinued" /> </Fields> <HeaderTemplate> <b>Product Details</b> </HeaderTemplate> <HeaderStyle BackColor="DarkBlue" /> </asp:DetailsView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-aspcheckboxfield-example-how-to.html
Example 65
asp.net DetailsView example: how to use DataFormatString property for formatting fields <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net DetailsView example: how to use DataFormatString property for formatting fields</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">DetailsView Formatting Fields Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT TOP 8 ProductID, ProductName, UnitPrice FROM Products" > </asp:SqlDataSource> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" ForeColor="AliceBlue" BackColor="DodgerBlue" BorderColor="LightSkyBlue" AutoGenerateRows="false" AllowPaging="true" > <Fields> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="UnitPrice" DataField="UnitPrice" DataFormatString="{0:C}" /> </Fields> <HeaderTemplate> <b>Product Details</b> </HeaderTemplate> <HeaderStyle BackColor="DarkBlue" /> </asp:DetailsView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-detailsview-example-how-to-use_14.html
Example 66
asp.net DetailsView example: how to insert data <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net DetailsView example: how to insert data</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">Example: DetailsView Insert</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" DataSourceMode="DataSet" SelectCommand="SELECT LastName, FirstName, Address FROM Employees" InsertCommand="INSERT INTO Employees (LastName, FirstName, Address) VALUES (@LastName, @FirstName, @Address)" > <InsertParameters> <asp:Parameter Name="LastName" Type="String" /> <asp:Parameter Name="FirstName" Type="String" /> <asp:Parameter Name="Address" Type="String" /> </InsertParameters> </asp:SqlDataSource> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" AutoGenerateInsertButton="true" AutoGenerateRows="false" BackColor="DarkOrange" BorderColor="Orange" ForeColor="Snow" > <Fields> <asp:BoundField HeaderText="Last Name" DataField="LastName" /> <asp:BoundField HeaderText="First Name" DataField="FirstName" /> <asp:BoundField HeaderText="Address" DataField="Address" /> </Fields> </asp:DetailsView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-detailsview-example-how-to_22.html
Example 67
DropDownList example: how to use DropDownList control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = "You selected: " + DropDownList1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DropDownList example: how to use DropDownList control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="ColorList" AssociatedControlID="DropDownList1"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="true" > <asp:ListItem>AliceBlue</asp:ListItem> <asp:ListItem>AntiqueWhite</asp:ListItem> <asp:ListItem>Aqua</asp:ListItem> <asp:ListItem>Aquamarine</asp:ListItem> <asp:ListItem>Azure</asp:ListItem> <asp:ListItem>Beige</asp:ListItem> <asp:ListItem>Bisque</asp:ListItem> <asp:ListItem>Black</asp:ListItem> <asp:ListItem>BlanchedAlmond</asp:ListItem> </asp:DropDownList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dropdownlist-example-how-to-use.html
Example 68
DropDownList example: how to validate DropDownList control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You selected: " + DropDownList1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DropDownList example: how to validate DropDownList control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Selected="True">Choose One</asp:ListItem> <asp:ListItem>BulletedList</asp:ListItem> <asp:ListItem>Button</asp:ListItem> <asp:ListItem>Calendar</asp:ListItem> <asp:ListItem>DataGrid</asp:ListItem> <asp:ListItem>DataList</asp:ListItem> <asp:ListItem>DataPager</asp:ListItem> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" InitialValue="Choose One" ErrorMessage="Select One!" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Validate DropDownList" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dropdownlist-example-how-to-validate.html
Example 69
DropDownList example: how to add ListItem dynamically <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { DropDownList1.Items.Add(new ListItem(TextBox1.Text)); Response.Write("Item Added: " + TextBox1.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DropDownList example: how to add ListItem dynamically</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Controls" AssociatedControlID="DropDownList1"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>CheckBox</asp:ListItem> <asp:ListItem>CheckBoxList</asp:ListItem> <asp:ListItem>RadioButton</asp:ListItem> <asp:ListItem>RadioButtonList</asp:ListItem> <asp:ListItem>DropDownList</asp:ListItem> <asp:ListItem>ListBox</asp:ListItem> <asp:ListItem>Button</asp:ListItem> </asp:DropDownList> <hr /> <asp:Label ID="Label2" runat="server" Text="Input Item Text" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Add Item" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dropdownlist-example-how-to-add.html
Example 70
DropDownList example: how to remove ListItem dynamically <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { DropDownList1.Items.Remove(DropDownList1.SelectedItem); Response.Write("Item Removed"); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DropDownList example: how to remove ListItem dynamically</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Controls" AssociatedControlID="DropDownList1"></asp:Label> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem>LinkButton</asp:ListItem> <asp:ListItem>LayoutEditorPart</asp:ListItem> <asp:ListItem>Label</asp:ListItem> <asp:ListItem>ImportCatalogPart</asp:ListItem> <asp:ListItem>ImageMap</asp:ListItem> <asp:ListItem>ImageButton</asp:ListItem> <asp:ListItem>Image</asp:ListItem> <asp:ListItem>HyperLinkField</asp:ListItem> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" Text="*"></asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Remove Item" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dropdownlist-example-how-to-remove.html
Example 71
How to create a directory programmatically in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Label1.Text = "Physical Application Path: " + Request.PhysicalApplicationPath; Label1.Text += "<br/ >Create a directory here..."; } protected void Button1_Click(object sender, System.EventArgs e) { string appPath = Request.PhysicalApplicationPath.ToString(); DirectoryInfo newDirectory = new DirectoryInfo(appPath+TextBox1.Text); try { newDirectory.Create(); Label2.Text = "Directory created successfully!"; } catch(Exception ex) { Label2.Text = "an error occured when create the directory!"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to create a directory programmatically in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net example: create directory</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Size="Large" ForeColor="Crimson" Font-Italic="true" > </asp:Label> <br /><br />
<asp:Label ID="Label3" runat="server" Text="Directory Name" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="HotPink" Text="Create Directory" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-create-directory.html
Example 72
How to get whether the specified directory exists or not in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { Label1.Text = "Physical Application Path: " + Request.PhysicalApplicationPath; string appPath = Request.PhysicalApplicationPath.ToString(); string directory1 = appPath + "Test"; string directory2 = appPath + "TestFolder"; Label1.Text += "<br /><br />Directory1: " + directory1; Label1.Text += "<br />Directory2: " + directory2; } } protected void Button1_Click(object sender, System.EventArgs e) { string dir1 = Request.PhysicalApplicationPath.ToString() + "Test"; string dir2 = Request.PhysicalApplicationPath.ToString() + "TestFolder"; DirectoryInfo path1 = new DirectoryInfo(dir1); bool path1Exists = path1.Exists; DirectoryInfo path2 = new DirectoryInfo(dir2); bool path2Exists = path2.Exists; Label2.Text = "Directory1 exists?: " + path1Exists.ToString(); Label2.Text += "<br />Directory2 exists?: " + path2Exists.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get whether the specified directory exists or not in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net example: directory exists?</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGreen" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server"
Font-Size="Large" ForeColor="Crimson" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="SeaGreen" Text="Test Directory Exists?" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-whether-specified-directory.html
Example 73
How to get the physical application path programmatically in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string phyAppPath = Request.PhysicalApplicationPath; Label1.Text = "Physical Application Path: " + phyAppPath; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to get the physical application path programmatically in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net example: get physical application path</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkRed" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Get Physical Application Path" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-physical-application-path.html
Example 74
How to check whether a file exists or not in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!this.IsPostBack) { TextBox1.Text += Request.PhysicalApplicationPath + "HP2133.jpg"; } } protected void Button1_Click(object sender, System.EventArgs e) { string filePath = Request.PhysicalApplicationPath + "HP2133.jpg"; FileInfo imageFile = new FileInfo(filePath); bool fileExists = imageFile.Exists; Label1.Text = "File exits?: " + fileExists.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to check whether a file exists or not in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net example: file exists</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="File" ForeColor="DarkOliveGreen" Font-Bold="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkOliveGreen" ForeColor="AliceBlue" > </asp:TextBox>
<br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="SaddleBrown" Text="Check File Exists?" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-check-whether-file-exists-or-not.html
Example 75
FileInfo class example: how to check file Exists or not in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("Text.Txt")); Label1.Text = "Your File Exists?: " + file.Exists.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>FileInfo class example: how to check file Exists or not in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/fileinfo-class-example-how-to-check_12.html
Example 76
FileInfo class example: how to get file FullName in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { System.IO.FileInfo file = new System.IO.FileInfo(Server.MapPath("Text.Txt")); Label1.Text = "Your File Full Name: " + file.FullName.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>FileInfo class example: how to get file FullName in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/fileinfo-class-example-how-to-get-file.html
Example 77
FileUpload example: how to use FileUpload control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { if (FileUpload1.HasFile) try { FileUpload1.SaveAs("C:\\UploadFolder\\"+FileUpload1.FileName); Label1.Text = "Uploaded File Name: " + FileUpload1.PostedFile.FileName + "<br />File Size: " + FileUpload1.PostedFile.ContentLength + "<br />File Type: " + FileUpload1.PostedFile.ContentType; } catch (Exception ex){ Label1.Text = "Error occured: " + ex.Message.ToString(); } else{ Label1.Text = "Select a file for upload"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>FileUpload example: how to use FileUpload control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="CornflowerBlue"></asp:Label> <br /><br /> <asp:FileUpload ID="FileUpload1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Upload this File" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/fileupload-example-how-to-use.html
Example 78
asp.net FileUpload example: how to upload file with specific extension <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string uploadFolder = Request.PhysicalApplicationPath+"UploadFolder\\" ; if (FileUpload1.HasFile) { string extension = Path.GetExtension(FileUpload1.PostedFile.FileName); if (extension.ToLower() == ".jpg") { FileUpload1.SaveAs(uploadFolder + FileUpload1.FileName); Label1.Text = "File uploaded successfully: " + FileUpload1.PostedFile.FileName; string imageSrc = "~/UploadFolder/" + FileUpload1.PostedFile.FileName; Image1.ImageUrl = imageSrc; Image1.BorderWidth = 2; Image1.BorderColor = System.Drawing.Color.SeaGreen; } else { Label1.Text = "This file extension not permitted: " + extension; } } else { Label1.Text = "Please select a file."; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net FileUpload example: how to upload file with specific extension</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net FileUpload example: specific file extension</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" >
</asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" ForeColor="DodgerBlue" Text="Choose a file for upload." Font-Bold="true" > </asp:Label> <br /> <asp:FileUpload ID="FileUpload1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" OnClick="Button1_Click" Text="Upload Now" /> <br /><br /> <asp:Image ID="Image1" runat="server" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-fileupload-example-how-to-upload.html
Example 79
asp.net FileUpload example: how to check (handle) error when upload a file <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { try { string uploadFolder = Request.PhysicalApplicationPath + "Upload\\"; FileUpload1.SaveAs(uploadFolder + FileUpload1.FileName); Label1.ForeColor = System.Drawing.Color.Green; Label1.Text = "File uploaded successfully: " + FileUpload1.PostedFile.FileName; } catch(Exception ex) { Label1.ForeColor = System.Drawing.Color.Red; Label1.Text = "an error occured.<br />"; Label1.Text += ex.Message; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net FileUpload example: how to check (handle) error when upload a file</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net FileUpload example: FileUpload Error Check</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" Font-Italic="true" Font-Bold="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" ForeColor="HotPink" Text="Choose a file for upload it." Font-Bold="true" > </asp:Label> <br />
<asp:FileUpload ID="FileUpload1" runat="server" BackColor="HotPink" ForeColor="AliceBlue" /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="HotPink" OnClick="Button1_Click" Text="Upload Now" /> <br /><br /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-fileupload-example-how-to-check_13.html
Example 80
asp.net FileUpload example: how to rename file when upload (change file name when upload) <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string uploadFolder = Request.PhysicalApplicationPath + "UploadFile\\"; if (FileUpload1.HasFile) { string extension = Path.GetExtension(FileUpload1.PostedFile.FileName); FileUpload1.SaveAs(uploadFolder + "Test"+ extension); Label1.Text = "File uploaded successfully as: " + "Test"+ extension; } else { Label1.Text = "First select a file."; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net FileUpload example: how to rename file when upload (change file name when upload)</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net FileUpload example: File Rename</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="OrangeRed" > </asp:Label> <br /><br /> <asp:FileUpload ID="FileUpload1" runat="server" BackColor="DeepPink" ForeColor="AliceBlue" /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="DeepPink" OnClick="Button1_Click" Text="Upload It" />
</div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-fileupload-example-how-to-rename.html
Example 81
asp.net SqlDataSource example: using FilterParameters, FilterExpression <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlDataSource example: using FilterParameters, FilterExpression</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">FilterParameters Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName FROM Products" > </asp:SqlDataSource> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ProductName" DataValueField="ProductID" AutoPostBack="true" ForeColor="SeaGreen" BackColor="DarkGreen" > </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products" FilterExpression="ProductID='{0}'" > <FilterParameters> <asp:ControlParameter Name="ProductID" ControlID="DropDownList1" PropertyName="SelectedValue" /> </FilterParameters> </asp:SqlDataSource> <br /><br /> <asp:GridView ID="GridView1" runat="server"
DataSourceID="SqlDataSource2" HeaderStyle-BackColor="HotPink" HeaderStyle-ForeColor="AntiqueWhite" BorderColor="SaddleBrown" ForeColor="SeaGreen" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-sqldatasource-example-using.html
Example 82
asp.net SqlCommand example: how to use SqlCommand <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ SqlConnection mySqlConnection; SqlCommand mySqlCommand; SqlDataReader mySqlDataReader; mySqlConnection = new SqlConnection(); mySqlConnection.ConnectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; mySqlCommand = new SqlCommand(); mySqlCommand.CommandText = "SELECT TOP 8 ProductID, ProductName, UnitPrice FROM Products"; mySqlCommand.CommandType = CommandType.Text; mySqlCommand.Connection = mySqlConnection; mySqlCommand.Connection.Open(); mySqlDataReader = mySqlCommand.ExecuteReader(CommandBehavior.CloseConnection); GridView1.DataSource = mySqlDataReader; GridView1.DataBind(); mySqlCommand.Dispose(); mySqlConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlCommand example: how to use SqlCommand</title> </head> <body> <form id="form1" runat="server"> <asp:Label ID="Label1" runat="server" Font-Size="X-Large" Font-Bold="true" ForeColor="Teal"> SqlCommand Example </asp:Label> <br /><br /> <div> <asp:GridView ID="GridView1" runat="server" BackColor="HotPink"
ForeColor="WhiteSmoke" HeaderStyle-BackColor="DarkOrange" BorderColor="Orange" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-sqlcommand-example-how-to-use.html
Example 83
asp.net SqlConnection example: how to use SqlConnection <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ SqlConnection myConnection; SqlCommand myCommand; SqlDataAdapter myAdapter; DataTable myTable; myConnection = new SqlConnection(); myConnection.ConnectionString = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; myCommand = new SqlCommand(); myCommand.CommandText = "SELECT CategoryID, CategoryName, Description FROM Categories"; myCommand.CommandType = CommandType.Text; myCommand.Connection = myConnection; myTable = new DataTable(); myAdapter = new SqlDataAdapter(); myAdapter.SelectCommand = myCommand; myAdapter.Fill(myTable); GridView1.DataSource = myTable.DefaultView; GridView1.DataBind(); myAdapter.Dispose(); myCommand.Dispose(); myConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlConnection example: how to use SqlConnection</title> </head> <body> <form id="form1" runat="server"> <h2 style="color:Red;">SqlConnection Example</h2> <div> <asp:GridView ID="GridView1" runat="server" BackColor="AliceBlue" ForeColor="HotPink"
HeaderStyle-BackColor="HotPink" HeaderStyle-ForeColor="AntiqueWhite" BorderColor="LightPink" GridLines="Horizontal" Font-Italic="true" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-sqlconnection-example-how-to-use.html
Example 84
asp.net Data Update example: using GridView and SqlDataSource <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net Data Update example: using GridView and SqlDataSource</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">GridView Data Update Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products" UpdateCommand="UPDATE Products SET ProductName=@ProductName, UnitPrice=@UnitPrice WHERE ProductID=@original_ProductID" OldValuesParameterFormatString="original_{0}" > <UpdateParameters> <asp:Parameter Name="ProductID" Type="Int32" /> <asp:Parameter Name="ProductName" Type="String" /> <asp:Parameter Name="UnitPrice" Type="Double" /> </UpdateParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="ProductID" AllowPaging="true" PageSize="10" AutoGenerateEditButton="true" BackColor="AliceBlue" ForeColor="SeaGreen" HeaderStyle-BackColor="SeaGreen" HeaderStyle-ForeColor="AliceBlue" BorderColor="LightGreen" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-data-update-example-using.html
Example 85
asp.net SqlDataSource and GridView example: adding SqlDataSource Programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void Button1_Click(object sender, System.EventArgs e) { SqlDataSource SqlDataSource1 = new SqlDataSource(); SqlDataSource1.ID = "SqlDataSource1"; Page.Controls.Add(SqlDataSource1); SqlDataSource1.ConnectionString = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; SqlDataSource1.SelectCommand = "SELECT ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID=1"; SqlDataSource1.Select(DataSourceSelectArguments.Empty); GridView1.DataSource = SqlDataSource1; GridView1.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlDataSource and GridView example: adding SqlDataSource Programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">SqlDataSource Programmatically</h2> <asp:Button ID="Button1" runat="server" Text="Add SqlDataSource and Bind GridView" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> <br /><br /> <asp:GridView ID="GridView1" runat="server" ForeColor="Crimson" BackColor="LightPink" HeaderStyle-BackColor="Crimson" HeaderStyle-ForeColor="AliceBlue" BorderColor="AliceBlue" GridLines="Horizontal" Font-Italic="true" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-sqldatasource-and-gridview.html
Example 86
asp.net GridView CheckBoxField example: how to use asp:CheckBoxField <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net GridView CheckBoxField example: how to use asp:CheckBoxField</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">GridView CheckBoxField Example</h2> <asp:Label ID="Label1" runat="server" Font-Italic="true" ForeColor="Red"></asp:Label> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice, Discontinued FROM Products" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" ForeColor="AliceBlue" BackColor="DodgerBlue" BorderColor="LightSkyBlue" HeaderStyle-BackColor="DarkBlue" AutoGenerateColumns="false" > <Columns> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice" /> <asp:CheckBoxField HeaderText="Discontinued" DataField="Discontinued" /> </Columns> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-gridview-checkboxfield-example.html
Example 87
asp.net GridView CommandField, SelectedRowStyle example: how to use CommandField <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net GridView CommandField, SelectedRowStyle example: how to use CommandField</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">GridView CommandField, SelectedRowStyle Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT CategoryID, CategoryName, Description FROM Categories" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" ForeColor="AliceBlue" BackColor="DarkSalmon" BorderColor="Salmon" HeaderStyle-BackColor="Crimson" AllowPaging="true" AutoGenerateColumns="false" DataKeyNames="CategoryID" AutoGenerateSelectButton="false" > <Columns> <asp:BoundField HeaderText="Category ID" DataField="CategoryID" /> <asp:BoundField HeaderText="Category Name" DataField="CategoryName" /> <asp:BoundField HeaderText="Description" DataField="Description" /> <asp:CommandField ShowSelectButton="true" ButtonType="Link" SelectText="Select" /> </Columns> <SelectedRowStyle BackColor="LightPink" Font-Italic="true" ForeColor="Crimson" /> </asp:GridView> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-gridview-commandfield.html
Example 88
asp.net GridView RowDataBound Event example: how to format specific row <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if(e.Row.RowType == DataControlRowType.DataRow) { Decimal ProductPrice = (decimal)DataBinder.Eval(e.Row.DataItem, "UnitPrice"); if(ProductPrice<20) { e.Row.ForeColor = System.Drawing.Color.Crimson; e.Row.Font.Italic = true; e.Row.BackColor = System.Drawing.Color.LightPink; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net GridView RowDataBound Event example: how to format specific row</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">GridView OnRowDataBound Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" ForeColor="AliceBlue" BackColor="DarkSalmon" BorderColor="Salmon" HeaderStyle-BackColor="Crimson" AllowPaging="true" AutoGenerateColumns="true" DataKeyNames="ProductID" OnRowDataBound="GridView1_RowDataBound" > </asp:GridView> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-gridview-rowdatabound-event.html
Example 89
asp.net GridView example: how to delete data <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net GridView example: how to delete data</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">Example: GridView Delete</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PubsConnectionString %>" SelectCommand="SELECT emp_id, fname, lname, hire_date FROM employee" DeleteCommand="DELETE FROM employee WHERE emp_id=@original_emp_id" OldValuesParameterFormatString="original_{0}" > <DeleteParameters> <asp:Parameter Name="emp_id" Type="String" /> </DeleteParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" AutoGenerateDeleteButton="true" AutoGenerateColumns="false" DataKeyNames="emp_id" BackColor="RosyBrown" ForeColor="SaddleBrown" HeaderStyle-BackColor="SaddleBrown" HeaderStyle-Font-Italic="false" HeaderStyle-ForeColor="RosyBrown" BorderColor="SaddleBrown" GridLines="Horizontal" Font-Italic="true" > <Columns> <asp:BoundField HeaderText="Employee ID" DataField="emp_id" /> <asp:BoundField HeaderText="First Name" DataField="fname" /> <asp:BoundField HeaderText="Last Name" DataField="lname" /> <asp:BoundField HeaderText="Hire Date" DataField="hire_date" DataFormatString="{0:D}" /> </Columns> </asp:GridView>
</div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-gridview-example-how-to-delete.html
Example 90
asp.net GridView example: a sample simple Master-Details page <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net GridView example: a sample simple Master-Details page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" ForeColor="LightSlateGray" Font-Bold="true" Font-Size="X-Large"> Master-Details Page Example </asp:Label> <br /><br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT CategoryID, CategoryName, Description FROM Categories" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateSelectButton="true" DataKeyNames="CategoryID" BackColor="HotPink" ForeColor="Snow" BorderColor="LightPink" HeaderStyle-BackColor="DarkOrange" > <SelectedRowStyle ForeColor="HotPink" BackColor="Snow" /> </asp:GridView> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID=@CategoryID" > <SelectParameters> <asp:ControlParameter Name="CategoryID" ControlID="GridView1" PropertyName="SelectedDataKey.Value" /> </SelectParameters> </asp:SqlDataSource>
<br /> <asp:Label ID="Label2" runat="server" Text="Products in selected Category" Font-Size="Large" ForeColor="LightSlateGray" > </asp:Label> <br /> <asp:GridView ID="GridView2" runat="server" DataSourceID="SqlDataSource2" AllowSorting="false" AllowPaging="true" PageSize="5" BackColor="SteelBlue" ForeColor="WhiteSmoke" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-gridview-example-sample-simple.html
Example 91
asp.net GridView HeaderStyle, AlternatingRowStyle example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net GridView HeaderStyle, AlternatingRowStyle example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">HeaderStyle, AlternatingRowStyle Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT TOP 5 ProductID, ProductName, UnitPrice FROM Products" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" BackColor="LightSlateGray" ForeColor="AliceBlue" BorderColor="LightYellow" > <Columns> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice" /> </Columns> <HeaderStyle BackColor="DarkSeaGreen" ForeColor="Gainsboro" /> <AlternatingRowStyle BackColor="SlateGray" /> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-gridview-headerstyle.html
Example 92
How to create and use GridView custom pager template (PagerTemplate) in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "First": {GridView1.PageIndex = 0; break;} case "Next": { GridView1.PageIndex++; break; } case "Previous": { GridView1.PageIndex--; break; } case "Last": { GridView1.PageIndex = GridView1.PageCount - 1; break; } } Label1.Text = "Current Page: " + (GridView1.PageIndex + 1) + " Total Page:" + GridView1.PageCount; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>How to create and use GridView custom pager template (PagerTemplate) in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">GridView Example: Using Custom PagerTemplate</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From Products" > </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Large" Font-Italic="true" ForeColor="DodgerBlue" > </asp:Label> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1"
AutoGenerateColumns="true" AllowPaging="true" PageSize="10" BorderColor="LightPink" Font-Names="Comic Sans MS" OnRowCommand="GridView1_RowCommand" Width="650" > <HeaderStyle BackColor="Crimson" ForeColor="Snow" Height="45" /> <RowStyle BackColor="OrangeRed" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="RosyBrown" /> <PagerTemplate> <asp:Button ID="Button1" runat="server" Text="First" CommandName="First" Height="35" Font-Bold="true" ForeColor="SaddleBrown" /> <asp:Button ID="Button2" runat="server" Text="Next" CommandName="Next" Height="35" Font-Bold="true" ForeColor="SaddleBrown" /> <asp:Button ID="Button3" runat="server" Text="Previous" CommandName="Previous" Height="35" Font-Bold="true" ForeColor="SaddleBrown" /> <asp:Button ID="Button4" runat="server" Text="Last" CommandName="Last" Height="35" Font-Bold="true" ForeColor="SaddleBrown" /> </PagerTemplate> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/10/how-to-create-and-use-gridview-custom.html
Example 93
GridView TemplateField OnClientClick event -using confirmation message for deleting records <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e) { if (e.Exception == null) { if (e.AffectedRows == 1) { Label1.Text = "One Record deleted successfully!"; Label1.ForeColor = Color.SeaGreen; } else { Label1.Text = "An error occured!"; Label1.ForeColor = Color.DeepPink; } } else { Label1.Text = "Error Details: " + e.Exception.Message; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>GridView TemplateField OnClientClick event -using confirmation message for deleting records</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">GridView Example: Using TemplateField OnClientClick Event</h2> <!-- Remove relation between Products and OrderDetails tables for test this example --> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From products" SelectCommandType="Text" DeleteCommand="Delete From Products Where ProductID=@original_ProductID" OldValuesParameterFormatString="original_{0}" OnDeleted="SqlDataSource1_Deleted" > <SelectParameters> <asp:Parameter Direction="Output" Name="Count" Type="Int32" /> </SelectParameters>
</asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Size="Large" Font-Italic="true" ForeColor="SeaGreen" > </asp:Label> <br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" AllowPaging="true" DataKeyNames="ProductID" PageSize="8" BorderColor="Salmon" AutoGenerateDeleteButton="false" Font-Names="Comic Sans MS" Width="850" > <HeaderStyle BackColor="Crimson" ForeColor="Snow" Height="45"/> <RowStyle BackColor="OrangeRed" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="BurlyWood" Font-Bold="true" Font-Size="X-Large" ForeColor="Snow" BorderColor="RosyBrown" /> <PagerSettings Mode="Numeric" /> <Columns> <asp:TemplateField HeaderText="Delete"> <ItemTemplate> <asp:Button ID="Button1" runat="server" Text="Delete" CommandName="Delete" OnClientClick="return confirm('Are you want to delete this record?')" Height="35" ForeColor="Crimson" Font-Bold="true" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="Quantity Per Unit" DataField="QuantityPerUnit" /> <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice"/> </Columns> </asp:GridView> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/10/gridview-templatefield-onclientclick.html
Example 94
How to use LinkButton control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void LinkButton1_Click(object sender, System.EventArgs e) { Label1.Text = "Your Country: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use LinkButton control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">LinkButton Example: Using LinkButton</h2> <asp:Label ID="Label1" runat="server" Font-Size="X-Large" Font-Italic="true" ForeColor="DodgerBlue" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="Crimson" Text="Country" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Crimson" ForeColor="LightGoldenrodYellow" Font-Bold="true" > </asp:TextBox> <br /><br /> <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" Text="Submit Country" > </asp:LinkButton> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-linkbutton-control-in-aspnet.html
Example 95
How to use OnClick event in LinkButton control <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void LinkButton1_Click(object sender, System.EventArgs e) { Label1.Text = "Your Address:<br />" + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use OnClick event in LinkButton control</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">LinkButton Example: OnClick Event</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="HotPink" Font-Italic="true" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Address" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="LightGoldenrodYellow" ForeColor="DodgerBlue" TextMode="MultiLine" > </asp:TextBox> <br /><br /> <asp:LinkButton ID="LinkButton1" runat="server" Text="Submit Address" OnClick="LinkButton1_Click" ForeColor="Crimson" Font-Size="Large"
BorderWidth="2" > </asp:LinkButton> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-onclick-event-in-linkbutton.html
Example 96
ListBox example: how to use ListBox control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = "Your favorite color: " + ListBox1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ListBox example: how to use ListBox control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="DarkOliveGreen"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Choose one Color" AssociatedControlID="ListBox1"></asp:Label> <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"> <asp:ListItem>DarkCyan</asp:ListItem> <asp:ListItem>DarkBlue</asp:ListItem> <asp:ListItem>DarkGoldenrod</asp:ListItem> <asp:ListItem>DarkGray</asp:ListItem> <asp:ListItem>DarkGreen</asp:ListItem> <asp:ListItem>DarkKhaki</asp:ListItem> <asp:ListItem>DarkMagenta</asp:ListItem> </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/listbox-example-how-to-use-listbox.html
Example 97
How to use AutoPostBack and OnSelectedIndexChanged in ListBox <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = "You Selected: " + ListBox1.SelectedItem.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use AutoPostBack and OnSelectedIndexChanged in ListBox</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net ListBox Example: Using AutoPostBack</h2> <asp:Label ID="Label1" runat="server" Text="asp.net Controls" Font-Bold="true" ForeColor="Crimson" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="asp.net Controls" Font-Bold="true" ForeColor="SteelBlue" > </asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" SelectionMode="Single" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" > <asp:ListItem>Repeater</asp:ListItem> <asp:ListItem>SqlDataSource</asp:ListItem> <asp:ListItem>SiteMapDataSource</asp:ListItem> <asp:ListItem>BehaviorEditorPart</asp:ListItem> <asp:ListItem>PropertyGridEditorPart</asp:ListItem> </asp:ListBox> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-autopostback-and.html
Example 98
How to use AutoPostBack with multiple selection mode in ListBox <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = "You Selected:<br /><i>"; foreach (ListItem li in ListBox1.Items) { if (li.Selected == true) { Label1.Text += li.Text + "<br />"; } } Label1.Text += ""; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use AutoPostBack with multiple selection mode in ListBox</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net ListBox Example: Using AutoPostBack</h2> <asp:Label ID="Label1" runat="server" Text="asp.net Controls" Font-Bold="true" ForeColor="SeaGreen" Font-Size="Large" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="asp.net Controls" Font-Bold="true" ForeColor="DodgerBlue" > </asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" SelectionMode="Multiple" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged"
BackColor="DodgerBlue" ForeColor="AliceBlue" > <asp:ListItem>ConnectionsZone</asp:ListItem> <asp:ListItem>EditorZone</asp:ListItem> <asp:ListItem>UpdateProgress</asp:ListItem> <asp:ListItem>LoginStatus</asp:ListItem> <asp:ListItem>Login</asp:ListItem> </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-autopostback-with-multiple.html
Example 99
How to add list item with item text and value in ListBox <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { ListItem li = new ListItem(); li.Text = TextBox1.Text.ToString(); li.Value = TextBox2.Text.ToString(); ListBox1.Items.Add(li); Label1.Text = "ListItem added in ListBox"; Label1.Text += "<br />Item Text: " + li.Text; Label1.Text += "<br />Item Value: " + li.Value; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add list item with item text and value in ListBox</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon">ListBox example: Add List Item</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="SeaGreen" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="asp.net controls" Font-Bold="true" ForeColor="DarkGreen" > </asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="DarkGreen" ForeColor="FloralWhite" > <asp:ListItem Value="1">UpdatePanel</asp:ListItem> <asp:ListItem Value="2">Timer</asp:ListItem> <asp:ListItem Value="3">EditorZone</asp:ListItem> </asp:ListBox>
<br /><br /> <asp:Label ID="Label3" runat="server" ForeColor="Crimson" Text="Item Text" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Crimson" ForeColor="Snow" > </asp:TextBox> <br /> <asp:Label ID="Label4" runat="server" ForeColor="Crimson" Text="Item Value" > </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="Crimson" ForeColor="Snow" > </asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Add List Item" Font-Bold="true" ForeColor="Crimson" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-add-list-item-with-item-text-and_8424.html
Example 100
Membership class example: how to get number of users online in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Label1.Text = "Now OnLine users: " + Membership.GetNumberOfUsersOnline().ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Membership class example: how to get number of users online in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>GetNumberOfUsersOnline method example</h2> <asp:LoginStatus ID="LoginStatus1" runat="server" /> <br /> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGoldenrod"></asp:Label> <br /><br /> <asp:LoginName ID="LoginName1" runat="server" FormatString="Hi {0}!" Font-Size="Large" ForeColor="Red" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/membership-class-example-how-to-get.html
Example 101
ChangePassword control example: how to change password in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ChangePassword control example: how to change password in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:LoginStatus ID="LoginStatus1" runat="server"/> <br /> <asp:LoginName ID="LoginName1" runat="server" FormatString="Hi {0}!" Font-Size="XX-Large" ForeColor="BurlyWood" /> <br /><br /> <asp:ChangePassword ID="ChangePassword1" runat="server" ></asp:ChangePassword> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/changepassword-control-example-how-to.html
Example 102
GetAllUsers method example: how to get user list in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { ListBox1.DataSource = Membership.GetAllUsers(); ListBox1.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>GetAllUsers method example: how to get user list in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>GetAllUsers Method Example</h2> <asp:Label ID="Label1" runat="server" Text="All Users" AssociatedControlID="ListBox1"></asp:Label> <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox> <br /> <asp:Button ID="Button1" runat="server" Text="Get All Users" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/getallusers-method-example-how-to-get.html
Example 103
DeleteUser method example: how to delete a user in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ DropDownListDataBind(); } } protected void Button1_Click(object sender, System.EventArgs e) { Membership.DeleteUser(DropDownList1.SelectedItem.Text); Label1.Text = "User deleted successfully!"; DropDownListDataBind(); } protected void DropDownListDataBind() { DropDownList1.DataSource = Membership.GetAllUsers(); DropDownList1.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DeleteUser method example: how to delete a user in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>DeleteUser method example</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DarkCyan"></asp:Label> <br /><br /> <b>Select user</b> <br /> <asp:DropDownList ID="DropDownList1" runat="server" BackColor="AliceBlue"></asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" Text="*"></asp:RequiredFieldValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Delete selected user" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/deleteuser-method-example-how-to-delete.html
Example 104
Path class example: how to get File Name in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Your submitted Path: " + TextBox1.Text.ToString() + "<br />File Name: " + Path.GetFileName(TextBox1.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Path class example: how to get File Name in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Path" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <asp:Button ID="Button1" runat="server" Text="Show File Name" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/path-class-example-how-to-get-file-name.html
Example 105
Path class example: how to get Temporary Directory in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.IO" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Temporary Directory: " + Path.GetTempPath(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Path class example: how to get Temporary Directory in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkMagenta"></asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Show Temporary Directory" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/path-class-example-how-to-get-temporary.html
Example 106
How to add a DropDownList control in PlaceHolder programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { String[] ControlList = { "HiddenField", "Calendar", "ImageMap", "Label", "Literal" }; DropDownList DropDownList1 = new DropDownList(); DropDownList1.BorderWidth = 2; DropDownList1.BorderColor = Color.SkyBlue; DropDownList1.BackColor = Color.AliceBlue; DropDownList1.ForeColor = Color.DeepPink; DropDownList1.Font.Italic = true; DropDownList1.Font.Size = FontUnit.Large; DropDownList1.Font.Name = "Comic Sans MS"; DropDownList1.Width = 250; DropDownList1.DataSource = ControlList; DropDownList1.DataBind(); PlaceHolder1.Controls.Add(DropDownList1); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add a DropDownList control in PlaceHolder programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">PlaceHolder Example: Add DropDownList</h2> <br /> <asp:PlaceHolder ID="PlaceHolder1" runat="server" > </asp:PlaceHolder> <br /><br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DarkBlue" Text="Add DropDownList Control" Height="45" OnClick="Button1_Click" Font-Bold="true" /> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/04/how-to-add-dropdownlist-control-in.html
Example 107
How to add a RadioButtonList control in PlaceHolder programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { String[] ControlList = { "HiddenField", "Button", "ImageMap", "TableRow", "Literal" }; RadioButtonList RadioButtonList1 = new RadioButtonList(); RadioButtonList1.BorderWidth = 3; RadioButtonList1.BorderColor = Color.Tomato; RadioButtonList1.BackColor = Color.DeepPink; RadioButtonList1.ForeColor = Color.Snow; RadioButtonList1.Font.Italic = true; RadioButtonList1.Font.Size = FontUnit.Large; RadioButtonList1.Font.Name = "Comic Sans MS"; RadioButtonList1.Width = 250; RadioButtonList1.DataSource = ControlList; RadioButtonList1.DataBind(); PlaceHolder1.Controls.Add(RadioButtonList1); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add a RadioButtonList control in PlaceHolder programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">PlaceHolder Example: Add RadioButtonList</h2> <br /> <asp:PlaceHolder ID="PlaceHolder1" runat="server" > </asp:PlaceHolder> <br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" Text="Add RadioButtonList Control" Height="45" OnClick="Button1_Click" Font-Bold="true" /> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/04/how-to-add-radiobuttonlist-control-in.html
Example 108
How to add a CheckBoxList control in PlaceHolder programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { String[] ControlList = { "HiddenField", "Button", "ImageMap", "Label", "Literal" }; CheckBoxList CheckBoxList1 = new CheckBoxList(); CheckBoxList1.BorderWidth = 3; CheckBoxList1.BorderColor = Color.IndianRed; CheckBoxList1.BackColor = Color.RosyBrown; CheckBoxList1.ForeColor = Color.FloralWhite; CheckBoxList1.Font.Italic = true; CheckBoxList1.Font.Size = FontUnit.Large; CheckBoxList1.Font.Name = "Comic Sans MS"; CheckBoxList1.Width = 250; CheckBoxList1.DataSource = ControlList; CheckBoxList1.DataBind(); PlaceHolder1.Controls.Add(CheckBoxList1); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add a CheckBoxList control in PlaceHolder programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">PlaceHolder Example: Add CheckBoxList</h2> <br /> <asp:PlaceHolder ID="PlaceHolder1" runat="server" > </asp:PlaceHolder> <br /> <asp:Button ID="Button1" runat="server" ForeColor="SaddleBrown" Text="Add CheckBoxList Control" Height="45" OnClick="Button1_Click" Font-Bold="true" /> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/04/how-to-add-checkboxlist-control-in.html
Example 109
How to add a Calendar control in PlaceHolder programmatically <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Calendar Calendar1 = new Calendar(); Calendar1.BackColor = Color.PaleVioletRed; Calendar1.ForeColor = Color.AliceBlue; Calendar1.BorderColor = Color.DarkRed; Calendar1.TitleStyle.BackColor = Color.Crimson; Calendar1.DayHeaderStyle.BackColor = Color.DarkSalmon; Calendar1.OtherMonthDayStyle.Font.Italic = true; Calendar1.OtherMonthDayStyle.BackColor = Color.RosyBrown; Calendar1.TitleStyle.Font.Bold = true; Calendar1.TodayDayStyle.BackColor = Color.Crimson; PlaceHolder1.Controls.Add(Calendar1); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add a Calendar control in PlaceHolder programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">PlaceHolder Example: Add Calendar</h2> <br /> <asp:PlaceHolder ID="PlaceHolder1" runat="server" > </asp:PlaceHolder> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="SaddleBrown" Text="Add Calendar Control" Height="45" OnClick="Button1_Click" Font-Bold="true" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/04/how-to-add-calendar-control-in.html
Example 110
How to use portal frameworks and web parts in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to use portal frameworks and web parts in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">Portal Frameworks and Web Parts</h2> <asp:WebPartManager ID="WebPartManager1" runat="server"> </asp:WebPartManager> <table> <tr> <td colspan="2"> <asp:WebPartZone ID="WebPartZone1" runat="server"> <ZoneTemplate> <asp:Label ID="Label1" runat="server" ForeColor="DodgerBlue" Text="This is Jenny's home page." Font-Bold="true" Font-Size="Large" Title="Page Header" > </asp:Label> </ZoneTemplate> </asp:WebPartZone> </td> </tr> <tr valign="top"> <td> <asp:WebPartZone ID="WebPartZone2" runat="server" LayoutOrientation="Horizontal"> <ZoneTemplate> <asp:Calendar ID="Calendar1" runat="server" Title="Jenny's Calendar" ForeColor="HotPink" BackColor="AliceBlue" BorderWidth="2" BorderStyle="Double" BorderColor="IndianRed" > <TitleStyle BackColor="HotPink"
ForeColor="AliceBlue" Font-Bold="true" /> <SelectedDayStyle BackColor="IndianRed" ForeColor="White" Font-Bold="true" BorderStyle="Dotted" BorderWidth="2" BorderColor="Pink" /> </asp:Calendar> </ZoneTemplate> </asp:WebPartZone> </td> <td> <asp:WebPartZone ID="WebPartZone3" runat="server"> <ZoneTemplate> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Doll.jpg" Title="Favorite Image" /> </ZoneTemplate> </asp:WebPartZone> </td> </tr> <tr> <td colspan="2" align="center"> <asp:WebPartZone ID="WebPartZone4" runat="server"> <ZoneTemplate> <asp:Label ID="Label2" runat="server" Font-Bold="true" Font-Italic="true" ForeColor="HotPink" Text="This is page footer" Title="Page Footer" > </asp:Label> </ZoneTemplate> </asp:WebPartZone> </td> </tr> </table> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/how-to-use-portal-frameworks-and-web.html
Example 111
How to use AutoPostBack feature in RadioButton <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void RadioButton_CheckedChanged(object sender, System.EventArgs e) { if (RadioButton1.Checked == true) { Label1.Text = "You choose color: " + RadioButton1.Text; } else { Label1.Text = "You choose color: " + RadioButton2.Text; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use AutoPostBack feature in RadioButton</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">RadioButton Example: AutoPostBack</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="HotPink" Font-Size="Larger" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="IndianRed" Text="Favorite Colors?" > </asp:Label> <br /> <asp:RadioButton ID="RadioButton1" runat="server" Text="ForestGreen" GroupName="Colors" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="true" Font-Size="Large" ForeColor="DarkOrange"
/> <asp:RadioButton ID="RadioButton2" runat="server" Text="FloralWhite" GroupName="Colors" OnCheckedChanged="RadioButton_CheckedChanged" AutoPostBack="true" Font-Size="Large" ForeColor="DarkOrange" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-autopostback-feature-in_25.html
Example 112
RadioButtonList example: how to use RadioButtonList control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text ="You Selected Collection: " + RadioButtonList1.SelectedItem.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>RadioButtonList example: how to use RadioButtonList control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem>ColdFusion</asp:ListItem> <asp:ListItem>Asp.Net</asp:ListItem> <asp:ListItem>PHP</asp:ListItem> </asp:RadioButtonList> <br /> <asp:Button ID="Button1" runat="server" Text="Show Selected Software" OnClick="Button1_Click" /> <hr /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/radiobuttonlist-example-how-to-use.html
Example 113
asp.net RadioButtonList Items.RemoveAt() example: how to remove item by index number <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int indexNumber = Convert.ToInt32(TextBox1.Text); RadioButtonList1.Items.RemoveAt(indexNumber); Label1.Text = "Item removed from index number: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RadioButtonList Items.RemoveAt() example: how to remove item by index number</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon">RadioButtonList Items.RemoveAt() example</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="Crimson"></asp:Label> <br /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" BorderWidth="1" BorderColor="Red"> <asp:ListItem>Lavender</asp:ListItem> <asp:ListItem>LavenderBlush</asp:ListItem> <asp:ListItem>LawnGreen</asp:ListItem> <asp:ListItem>LemonChiffon</asp:ListItem> </asp:RadioButtonList> <br /><br /> <b style="color:Navy">Index start from 0</b> <br /> <asp:Label ID="Label2" runat="server" Text="Position[Index]" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Aqua"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="TextBox1" Operator="DataTypeCheck" Type="Integer" ErrorMessage="Input valid number!"></asp:CompareValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Remove Item" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-radiobuttonlist-itemsremoveat.html
Example 114
asp.net RadioButtonList Items.FindByText() method example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { RadioButtonList1.Items.FindByText(TextBox1.Text).Selected = true; Label1.Text = "RadioButtonList Item selected."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RadioButtonList Items.FindByText() method example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">RadioButtonList Items.FindByText() Example</h2> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large"></asp:Label> <br /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" BackColor="AliceBlue" ForeColor="DarkGreen"> <asp:ListItem>LightPink</asp:ListItem> <asp:ListItem>LightSalmon</asp:ListItem> <asp:ListItem>LightSeaGreen</asp:ListItem> </asp:RadioButtonList> <hr /> <asp:Label ID="Label2" runat="server" Text="RadioButtonList Item Text" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="AliceBlue" ForeColor="RoyalBlue"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text=" Select RadioButtonList Item" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-radiobuttonlist-itemsfindbytext.html
Example 115
asp.net RadioButtonList Items.Clear() example: how to remove all Items from RadioButtonList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { RadioButtonList1.Items.Clear(); Label1.Text = "RadioButtonList is empty."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RadioButtonList Items.Clear() example: how to remove all Items from RadioButtonList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon">RadioButtonList Items.Clear() example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGoldenrod"></asp:Label> <hr /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" BackColor="Azure" ForeColor="Magenta" RepeatColumns="2"> <asp:ListItem>Magenta</asp:ListItem> <asp:ListItem>Maroon</asp:ListItem> <asp:ListItem>MediumAquaMarine</asp:ListItem> <asp:ListItem>MediumBlue</asp:ListItem> <asp:ListItem>MediumOrchid</asp:ListItem> <asp:ListItem>MediumPurple</asp:ListItem> <asp:ListItem>MediumSeaGreen</asp:ListItem> </asp:RadioButtonList> <hr /> <asp:Button ID="Button1" runat="server" Text="Clear RadioButtonList" OnClick="Button1_Click" Font-Bold="true" ForeColor="DarkGoldenrod" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-radiobuttonlist-itemsclear.html
Example 116
asp.net RadioButtonList Items.FindByValue() method example <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { RadioButtonList1.Items.FindByValue(TextBox1.Text).Selected = true; Label1.Text = "RadioButtonList Item selected."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RadioButtonList Items.FindByValue() method example</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">RadioButtonList Items.FindByValue() Example</h2> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large"></asp:Label> <br /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" BackColor="LightYellow" ForeColor="DarkGreen" RepeatColumns="2"> <asp:ListItem Value="#87CEFA">LightSkyBlue</asp:ListItem> <asp:ListItem Value="#778899">LightSlateGray</asp:ListItem> <asp:ListItem Value="#B0C4DE">LightSteelBlue</asp:ListItem> <asp:ListItem Value="#FFFFE0">LightYellow</asp:ListItem> <asp:ListItem Value="#00FF00">Lime</asp:ListItem> </asp:RadioButtonList> <hr /> <asp:Label ID="Label2" runat="server" Text="RadioButtonList Item Value" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="AliceBlue" ForeColor="RoyalBlue"></asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text=" Select RadioButtonList Item" OnClick="Button1_Click" Font-Bold="true" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/aspnet-radiobuttonlist-itemsfindbyvalue.html
Example 117
asp.net RadioButtonList example: populate from XmlDataSource <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RadioButtonList example: populate from XmlDataSource</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Fuchsia">Example: Populate RadioButtonList From XmlDataSource</h2> <asp:RadioButtonList ID="RadioButtonList1" runat="server" DataSourceID="XmlDataSource1" DataTextField="Name" DataValueField="ID" BackColor="DodgerBlue" ForeColor="AliceBlue" BorderWidth="2" BorderColor="DarkBlue" RepeatColumns="3" > </asp:RadioButtonList> <asp:XmlDataSource ID="XmlDataSource1" runat="server"> <Data> <Controls> <Control ID="1" Name="TreeView" /> <Control ID="2" Name="Login" /> <Control ID="3" Name="LoginView" /> <Control ID="4" Name="PasswordRecovery" /> <Control ID="5" Name="LoginStatus" /> </Controls> </Data> </asp:XmlDataSource> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-radiobuttonlist-example-populate.html
Example 118
How to add list item in RadioButtonList programmatically <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { ListItem li = new ListItem(); li.Text = TextBox1.Text.ToString(); RadioButtonList1.Items.Add(li); Label1.Text = "ListItem added in RadioButtonList: " + li.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add list item in RadioButtonList programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">RadioButtonList example: Add List Item</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Color List" Font-Bold="true" ForeColor="Crimson" > </asp:Label> <br /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" BackColor="Crimson" ForeColor="FloralWhite" RepeatColumns="2" > <asp:ListItem>SpringGreen</asp:ListItem> <asp:ListItem>Turquoise</asp:ListItem> <asp:ListItem>Violet</asp:ListItem> <asp:ListItem>SteelBlue</asp:ListItem> <asp:ListItem>Snow</asp:ListItem> </asp:RadioButtonList>
<br /><br /> <asp:Label ID="Label3" runat="server" ForeColor="Crimson" Text="Item Text" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Crimson" ForeColor="Snow" > </asp:TextBox> <br /> <asp:Button ID="Button1" runat="server" Text="Add List Item" Font-Bold="true" ForeColor="Crimson" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-add-list-item-in-radiobuttonlist.html
Example 119
How to use AutoPostBack feature in RadioButtonList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e) { Label1.Text = "You selected: " + RadioButtonList1.SelectedItem.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use AutoPostBack feature in RadioButtonList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">RadioButtonList: AutoPostBack</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="SeaGreen" Font-Size="Large" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Font-Bold="true" ForeColor="DarkCyan" Text="asp.net controls" > </asp:Label> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" BackColor="DarkCyan" ForeColor="AliceBlue" > <asp:ListItem>HyperLink</asp:ListItem> <asp:ListItem>LayoutEditorPart</asp:ListItem> <asp:ListItem>BehaviorEditorPart</asp:ListItem> <asp:ListItem>Localize</asp:ListItem> <asp:ListItem>ImageMap</asp:ListItem> </asp:RadioButtonList> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-autopostback-feature-in_18.html
Example 120
asp.net RangeValidator: how to validate date range (Validation Data Type Date) <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { Label1.Font.Italic = true; Label1.Font.Bold = true; Label1.ForeColor = System.Drawing.Color.Crimson; Label1.Font.Size = FontUnit.Large; TextBox1.ForeColor = System.Drawing.Color.DodgerBlue; Button1.Font.Bold = true; Button1.ForeColor = System.Drawing.Color.DarkGreen; Calendar1.ForeColor = System.Drawing.Color.AliceBlue; Calendar1.BackColor = System.Drawing.Color.DodgerBlue; Calendar1.TitleStyle.BackColor = System.Drawing.Color.DarkGreen; Calendar1.DayHeaderStyle.BackColor = System.Drawing.Color.SeaGreen; Calendar1.SelectedDayStyle.BackColor = System.Drawing.Color.LightBlue; Calendar1.SelectedDayStyle.ForeColor = System.Drawing.Color.DarkGreen; Calendar1.BorderColor = System.Drawing.Color.DarkBlue; Calendar1.TodayDayStyle.BackColor = System.Drawing.Color.SkyBlue; Calendar1.SelectionMode = CalendarSelectionMode.Day; RangeValidator1.ControlToValidate = "TextBox1"; RangeValidator1.Type = ValidationDataType.Date; RangeValidator1.MinimumValue = DateTime.Now.ToShortDateString(); RangeValidator1.MaximumValue = DateTime.Now.AddDays(7).ToShortDateString(); RangeValidator1.ErrorMessage = "Select date between today to next 7 day!"; } } protected void Calendar1_SelectionChanged(object sender, EventArgs e) { TextBox1.Text = Calendar1.SelectedDate.ToShortDateString(); } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your arrival date is: " + Calendar1.SelectedDate.ToLongDateString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server">
<title>asp.net RangeValidator: how to validate date range (Validation Data Type Date)</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">RnageValidator: Date Range</h2> <asp:Label ID="Label1" runat="server"> </asp:Label> <br /><br /> <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator> <br /> <b>Arrival Date</b> <asp:Calendar ID="Calendar1" runat="server" OnSelectionChanged="Calendar1_SelectionChanged" > </asp:Calendar> <asp:RangeValidator ID="RangeValidator1" runat="server"> </asp:RangeValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit Arrival Date" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-rangevalidator-how-to-validate.html
Example 121
asp.net RangeValidator: how to validate data type integer <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Number is valid: " + DropDownList1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RangeValidator: how to validate data type integer</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">RangeValidator: Data Type Integer</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" > </asp:Label> <br /><br /> <b>Select a number between 40 to 60</b> <br /> <asp:DropDownList ID="DropDownList1" runat="server" BackColor="DodgerBlue" ForeColor="Snow" > <asp:ListItem>10</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>30</asp:ListItem> <asp:ListItem>40</asp:ListItem> <asp:ListItem>50</asp:ListItem> <asp:ListItem>60</asp:ListItem> <asp:ListItem>70</asp:ListItem> <asp:ListItem>80</asp:ListItem> <asp:ListItem>90</asp:ListItem> <asp:ListItem>100</asp:ListItem> </asp:DropDownList> <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="DropDownList1" Type="Integer" MinimumValue="40"
MaximumValue="60" ErrorMessage="Select Number between 40 to 60" > </asp:RangeValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Text="Submit Number" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-rangevalidator-how-to-validate_03.html
Example 122
asp.net RegularExpressionValidator example: how to validate email address <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your email: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RegularExpressionValidator example: how to validate email address</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">RegularExpressionValidator: email</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Italic="true" Font-Size="Large" ForeColor="SeaGreen" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Email" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" > </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" ControlToValidate="TextBox1" ErrorMessage="Input valid email address!" > </asp:RegularExpressionValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit email" Font-Bold="true" ForeColor="DodgerBlue" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-regularexpressionvalidator.html
Example 123
asp.net RegularExpressionValidator example: how to validate URL <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Home Page:<br/ >" + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RegularExpressionValidator example: how to validate URL</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">RegularExpressionValidator: Internet URL</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Italic="true" Font-Size="Large" ForeColor="HotPink" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Home Page" Font-Bold="true" ForeColor="Teal" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Teal" ForeColor="Snow" Width="250" > </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?" ControlToValidate="TextBox1" ErrorMessage="Input valid Internet URL!" ></asp:RegularExpressionValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit URL" Font-Bold="true" ForeColor="Teal" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-regularexpressionvalidator_03.html
Example 124
asp.net RegularExpressionValidator example: how to validate U.S. Zip Code <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Label1.Font.Bold = true; Label1.Font.Italic = true; Label1.Font.Size = FontUnit.Large; Label1.ForeColor = System.Drawing.Color.HotPink; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Zip Code: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RegularExpressionValidator example: how to validate U.S. Zip Code</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">RegularExpressionValidator: U.S. Zip Code</h2> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="U.S. Zip Code" Font-Bold="true" ForeColor="DodgerBlue" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" > </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="\d{5}(-\d{4})?" ControlToValidate="TextBox1" ErrorMessage="Input valid U.S. Zip Code!" ></asp:RegularExpressionValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Zip Code" Font-Bold="true" ForeColor="Crimson" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-regularexpressionvalidator_7607.html
Example 125
asp.net RegularExpressionValidator example: how to validate U.S. Phone Number <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Label1.Font.Bold = true; Label1.Font.Italic = true; Label1.Font.Size = FontUnit.Large; Label1.ForeColor = System.Drawing.Color.SeaGreen; TextBox1.BackColor = System.Drawing.Color.Tomato; TextBox1.ForeColor = System.Drawing.Color.Snow; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Phone Number: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RegularExpressionValidator example: how to validate U.S. Phone Number</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">RegularExpressionValidator: U.S. Phone Number</h2> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="U.S. Phone Number" Font-Bold="true" ForeColor="DodgerBlue" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1"
runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" ControlToValidate="TextBox1" ErrorMessage="Input valid U.S. Phone Number!" ></asp:RegularExpressionValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Phone Number" Font-Bold="true" ForeColor="DodgerBlue" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-regularexpressionvalidator_2294.html
Example 126
asp.net RegularExpressionValidator: how to validate U.S. Social Security Number <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { Label1.Font.Bold = true; Label1.Font.Italic = true; Label1.Font.Size = FontUnit.Large; Label1.ForeColor = System.Drawing.Color.Crimson; TextBox1.BackColor = System.Drawing.Color.SlateBlue; TextBox1.ForeColor = System.Drawing.Color.AliceBlue; Button1.Font.Bold = true; Button1.ForeColor = System.Drawing.Color.SlateBlue; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Social Security Number: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RegularExpressionValidator: how to validate U.S. Social Security Number</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">RegularExpressionValidator<br /><i>U.S. Social Security Number</i></h2> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="U.S. Social Security Number" Font-Bold="true" ForeColor="SlateBlue" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" >
</asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*" > </asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationExpression="\d{3}-\d{2}-\d{4}" ControlToValidate="TextBox1" ErrorMessage="Input valid U.S. Social Security Number!" ></asp:RegularExpressionValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit U.S. Social Security Number" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-regularexpressionvalidator-how.html
Example 127
Validation example: how to use RequiredFieldValidator in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e){ Label1.Text = "Your name: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Validation example: how to use RequiredFieldValidator in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="CadetBlue"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Input your name!"> </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/validation-example-how-to-use.html
Example 128
ListBox example: how to validate ListBox control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You selected: " + ListBox1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ListBox example: how to validate ListBox control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server"> <asp:ListItem Selected="True">Choose a Control</asp:ListItem> <asp:ListItem>CheckBox</asp:ListItem> <asp:ListItem>CheckBoxList</asp:ListItem> <asp:ListItem>DropDownList</asp:ListItem> <asp:ListItem>RadioButton</asp:ListItem> <asp:ListItem>RadioButtonList</asp:ListItem> <asp:ListItem>GridView</asp:ListItem> <asp:ListItem>TreeView</asp:ListItem> </asp:ListBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ListBox1" InitialValue="Choose a Control" ErrorMessage="Select an Item!" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Validate ListBox" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/listbox-example-how-to-validate-listbox.html
Example 129
DropDownList example: how to validate DropDownList control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You selected: " + DropDownList1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DropDownList example: how to validate DropDownList control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson"></asp:Label> <br /> <asp:DropDownList ID="DropDownList1" runat="server"> <asp:ListItem Selected="True">Choose One</asp:ListItem> <asp:ListItem>BulletedList</asp:ListItem> <asp:ListItem>Button</asp:ListItem> <asp:ListItem>Calendar</asp:ListItem> <asp:ListItem>DataGrid</asp:ListItem> <asp:ListItem>DataList</asp:ListItem> <asp:ListItem>DataPager</asp:ListItem> </asp:DropDownList> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1" InitialValue="Choose One" ErrorMessage="Select One!" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Validate DropDownList" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/dropdownlist-example-how-to-validate.html
Example 130
asp.net RequiredFieldValidator example: how to validate RadioButtonList <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your favorite: "; Label1.Text += RadioButtonList1.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net RequiredFieldValidator example: how to validate RadioButtonList</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">RadioButtonList Validation</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Favorite" Font-Bold="true" ForeColor="DodgerBlue" > </asp:Label> <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3" BackColor="DodgerBlue" ForeColor="AliceBlue" BorderColor="DarkBlue" BorderWidth="2" > <asp:ListItem>CheckBoxList</asp:ListItem> <asp:ListItem>TreeView</asp:ListItem> <asp:ListItem>Button</asp:ListItem> <asp:ListItem>SqlDataSource</asp:ListItem> <asp:ListItem>GridView</asp:ListItem> <asp:ListItem>Calendar</asp:ListItem> <asp:ListItem>BulletedList</asp:ListItem>
</asp:RadioButtonList> <asp:RequiredFieldValidator ID="ReqiredFieldValidator1" runat="server" ControlToValidate="RadioButtonList1" ErrorMessage="Select your favorite!" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" Text="Submit Favorite" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/aspnet-requiredfieldvalidator-example.html
Example 131
CreateRole method example: how to create a role programmatically in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e){ if(!Page.IsPostBack){ ListBoxDataBind(); } } protected void Button1_Click(object sender, System.EventArgs e) { if(Roles.RoleExists(TextBox1.Text.ToString())== false){ Roles.CreateRole(TextBox1.Text.ToString()); Label1.Text = TextBox1.Text.ToString() + " Role created successfully!"; ListBoxDataBind(); } else{ Label1.Text = TextBox1.Text.ToString() + " Role already exists"; } } protected void ListBoxDataBind() { ListBox1.DataSource = Roles.GetAllRoles(); ListBox1.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>CreateRole method example: how to create a role programmatically in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>CreateRole method example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkGoldenrod" ></asp:Label> <br /><br /> <asp:ListBox ID="ListBox1" runat="server"></asp:ListBox> <hr /> <asp:Label ID="Label2" runat="server" Text="Role Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" Text="*"></asp:RequiredFieldValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Create Role" OnClick="Button1_Click" /> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2008/10/createrole-method-example-how-to-create.html
Example 132
DeleteRole method example: how to delete a role programmatically in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ DropDownListDataBind(); } } protected void DropDownListDataBind() { DropDownlist1.DataSource = Roles.GetAllRoles(); DropDownlist1.DataBind(); } protected void Button1_Click(object sender, System.EventArgs e) { Roles.DeleteRole(DropDownlist1.SelectedItem.Text.ToString(), false); Label1.Text = "Selected role deleted successfully!"; DropDownListDataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>DeleteRole method example: how to delete a role programmatically in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>DeleteRole method example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkMagenta"></asp:Label> <br /><br /> <b>Select a role for delete it.</b> <asp:DropDownList ID="DropDownlist1" runat="server"></asp:DropDownList> <br /> <asp:Button ID="Button1" runat="server" Text="Delete selected role" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/deleterole-method-example-how-to-delete.html
Example 133
GetUsersInRole method example: how to get all the users in a role programmatically <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ ListBox1.DataSource = Roles.GetAllRoles(); ListBox1.DataBind(); } } protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { ListBox2.DataSource = Roles.GetUsersInRole(ListBox1.SelectedItem.Text.ToString()); ListBox2.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>GetUsersInRole method example: how to get all the users in a role programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2>GetUsersInRole method example</h2> <b>All Roles</b> <br /> <asp:ListBox ID="ListBox1" runat="server" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" AutoPostBack="true"></asp:ListBox> <br /><br /> <b style="color:Red">All users in selected role</b> <br /> <asp:ListBox ID="ListBox2" runat="server"></asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/getusersinrole-method-example-how-to.html
Example 134
AddUserToRole method example: programmatically adding user to role in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if(!Page.IsPostBack){ ListBox1.DataSource = Roles.GetAllRoles(); ListBox1.DataBind(); ListBox2.DataSource = Membership.GetAllUsers(); ListBox2.DataBind(); } } protected void ListBox1_SelectedIndexChanged(object sender, System.EventArgs e) { ListBox3.DataSource = Roles.GetUsersInRole(ListBox1.SelectedItem.Text.ToString()); ListBox3.DataBind(); } protected void Button1_Click(object sender, System.EventArgs e) { Roles.AddUserToRole(ListBox2.SelectedItem.Text.ToString(), ListBox1.SelectedItem.Text.ToString()); ListBox3.DataSource = Roles.GetUsersInRole(ListBox1.SelectedItem.Text.ToString()); ListBox3.DataBind(); Label1.Text = ListBox2.SelectedItem.Text.ToString() + " User Added in " + ListBox1.SelectedItem.Text.ToString() + " Role successfully!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>AddUserToRole method example: programmatically adding user to role in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2>Add user to role example</h2> <asp:Label ID="Label1" runat="server" Font-Size="Larger" ForeColor="Crimson"></asp:Label> <br /><br /> <b>All Roles</b> <br /> <asp:ListBox ID="ListBox1" runat="server" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" AutoPostBack="true"></asp:ListBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ListBox1" Text="*"></asp:RequiredFieldValidator>
<br /><br /> <b>All Users</b> <br /> <asp:ListBox ID="ListBox2" runat="server"></asp:ListBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="ListBox2" Text="*"></asp:RequiredFieldValidator> <hr /> <b style="color:Fuchsia">All users in selected role</b> <br /> <asp:ListBox ID="ListBox3" runat="server"></asp:ListBox> <br /> <asp:Button ID="Button1" runat="server" Text="Add selected user in selected role" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/addusertorole-method-example.html
Example 135
asp.net session IsNewSession example: how to get whether the session was created only for the current request or not <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["ZipCode"] = "12345"; Label1.Text = "Session read<br />"; Label1.Text += "Session IsNewSession?: " + Session.IsNewSession; Label1.Text += "<br />Zip Code :" + Session["ZipCode"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session IsNewSession example: how to get whether the session was created only for the current request or not</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Blue">asp.net session example: Session IsNewSession?</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="OrangeRed" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-isnewsession-example-how.html
Example 136
asp.net session Add example: how to add an item in the session <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["CityID"] = "10"; Session["CityName"] = "Paris"; Label1.Text = "Session read...<br />"; Label1.Text += "Total session items: " + Session.Count; Label1.Text += "<br />City ID : " + Session["CityID"]; Label1.Text += "<br />City Name : " + Session["CityName"]; Label1.Text += "<br><br />Now add an item in session."; Session.Add("EmployeeName","Jenny"); Label1.Text += "<br />Now Total session items: " + Session.Count; Label1.Text += "<br />City ID : " + Session["CityID"]; Label1.Text += "<br />City Name : " + Session["CityName"]; Label1.Text += "<br />Employee Name : " + Session["EmployeeName"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session Add example: how to add an item in the session</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net session example: Session Add</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="IndianRed" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-add-example-how-to-add.html
Example 137
asp.net session Clear example: how to clear the current session data (remove all the session items) <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["FavoriteSoftware"] = "Adobe ColdFusion"; Label1.Text = "Session read...<br />"; Label1.Text += "Favorite Software : " + Session["FavoriteSoftware"]; Label1.Text += "<br />SessionID : " + Session.SessionID; Label1.Text += "<br> Now clear the current session data."; Session.Clear(); Label1.Text += "<br /><br />SessionID : " + Session.SessionID; Label1.Text += "<br />Favorite Software[after clear]: " + Session["FavoriteSoftware"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session Clear example: how to clear the current session data (remove all the session items)</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net session example: Session Clear</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkMagenta" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-clear-example-how-to.html
Example 138
asp.net session example: how to count session items for the current session collection <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["ProductID"] = "101"; Session["ProductName"] = "Acer Aspire ONE"; Session["ProductDescription"] = "Mini Laptop"; Label1.Text = "Session read<br />"; Label1.Text += "Session Items Count:" + Session.Count; Label1.Text += "<br />Product ID :" + Session["ProductID"]; Label1.Text += "<br />Product Name :" + Session["ProductName"]; Label1.Text += "<br />Product Description :" + Session["ProductDescription"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session example: how to count session items for the current session collection</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net session example: SessionCount</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-example-how-to-count.html
Example 139
asp.net session example: how to get SessionID (session id) for the current client <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["ProductName"] = "HP-2133 Laptop"; Label1.Text = "Session read<br />"; Label1.Text += "SessionID: " + Session.SessionID; Label1.Text += "<br />Product Name: " + Session["ProductName"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net session example: how to get SessionID (session id) for the current client</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net session example: Get SessionID</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Teal" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-example-how-to-get.html
Example 140
asp.net session IsReadOnly example: how to get the session is read only or not <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["Bird"] = "Parrot"; Label1.Text = "Session read<br />"; Label1.Text += "Session IsReadOnly?: " + Session.IsReadOnly; Label1.Text += "<br />Bird : " + Session["Bird"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session IsReadOnly example: how to get the session is read only or not</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Purple">asp.net session example: Session IsReadOnly?</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Firebrick" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-isreadonly-example-how.html
Example 141
asp.net session mode example: get how asp.net stores session state information <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["Email"] = "[email protected]"; Label1.Text = "Session read<br />"; Label1.Text += "Session Mode: " + Session.Mode; Label1.Text += "<br />Email : " + Session["Email"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session mode example: get how asp.net stores session state information</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon">asp.net session example: Session Mode?</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="CadetBlue" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-mode-example-get-how.html
Example 142
asp.net session Remove example: how to remove an item from session <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["EmployeeID"] = "11"; Session["EmployeeName"] = "Jenny Jones"; Session["City"] = "Rome"; Label1.Text = "Session read...<br />"; Label1.Text += "Employee ID :" + Session["EmployeeID"]; Label1.Text += "<br />Employee Name :" + Session["EmployeeName"]; Session.Remove("EmployeeName"); Label1.Text += "<br /><br />Now remove the item [EmployeeName]"; Label1.Text += "<br />Employee ID :" + Session["EmployeeID"]; Label1.Text += "<br />Employee Name :" + Session["EmployeeName"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session Remove example: how to remove an item from session</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net session example: Remove</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DeepPink" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-remove-example-how-to.html
Example 143
asp.net session RemoveAll example: how to remove all keys and values from the session-state collection <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["CustomerID"] = "12"; Session["CustomerName"] = "Ben Forta"; Label1.Text = "Session read...<br />"; Label1.Text += "Customer ID : " + Session["CustomerID"]; Label1.Text += "<br />Customer Name : " + Session["CustomerName"]; Label1.Text += "<br> Now remove all items from session."; Session.RemoveAll(); Label1.Text += "<br /><br />Customer ID : " + Session["CustomerID"]; Label1.Text += "<br />Customer Name : " + Session["CustomerName"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session RemoveAll example: how to remove all keys and values from the session-state collection</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net session example: Session RemoveAll</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="RosyBrown" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-removeall-example-how-to.html
Example 144
asp.net session RemoveAt example: how to remove an item from the session at specified index position <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["TownID"] = "5"; Session["TownName"] = "Rome"; Session["Contact"] = "Jones"; Label1.Text = "Session read...<br />"; Label1.Text += "Town ID : " + Session["TownID"]; Label1.Text += "<br />Town Name : " + Session["TownName"]; Label1.Text += "<br />Contact Name : " + Session["Contact"]; Label1.Text += "<br> Now remove item from session at index position 1."; Session.RemoveAt(1); Label1.Text += "<br /><br />Town ID : " + Session["TownID"]; Label1.Text += "<br />Town Name : " + Session["TownName"]; Label1.Text += "<br />Contact Name : " + Session["Contact"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session RemoveAt example: how to remove an item from the session at specified index position</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net session example: Session RemoveAt</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="IndianRed" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-removeat-example-how-to.html
Example 145
asp.net session Timeout example: how to get session time out value <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { Session["FavoritePhone"] = "Nokia E61"; Label1.Text = "Session read...<br />"; Label1.Text += "Session Timeout[Minutes]: " + Session.Timeout; Label1.Text += "<br />Favorite Phone : " + Session["FavoritePhone"]; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net session Timeout example: how to get session time out value</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net session example: Session Timeout</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="CornflowerBlue" > </asp:Label> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-session-timeout-example-how-to.html
Example 146
asp.net SqlDataSource example: programmatically adding SqlDataSource and ControlParameter <%@ Page Language="C#" %> <%@ Import Namespace="System.Web.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void DropDwonList1_SelectedIndexChanged(object sender, System.EventArgs e) { SqlDataSource SqlDataSource2 = new SqlDataSource(); SqlDataSource2.ID = "SqlDataSource2"; Page.Controls.Add(SqlDataSource2); SqlDataSource2.ConnectionString = WebConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString; SqlDataSource2.SelectCommand = "Select ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID=@CategoryID"; ControlParameter CategoryID = new ControlParameter(); CategoryID.Name = "CategoryID"; CategoryID.ControlID = "DropDownList1"; CategoryID.PropertyName = "SelectedValue"; SqlDataSource2.SelectParameters.Clear(); SqlDataSource2.SelectParameters.Add(CategoryID); SqlDataSource2.Select(DataSourceSelectArguments.Empty); GridView1.DataSource = SqlDataSource2; GridView1.DataBind(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlDataSource example: programmatically adding SqlDataSource and ControlParameter</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">SqlDataSource and ControlParameter</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT CategoryID, CategoryName FROM Categories" > </asp:SqlDataSource> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" OnSelectedIndexChanged="DropDwonList1_SelectedIndexChanged" AutoPostBack="true"
ForeColor="AliceBlue" BackColor="CornflowerBlue" > </asp:DropDownList> <asp:GridView ID="GridView1" runat="server" BackColor="CornflowerBlue" ForeColor="AliceBlue" HeaderStyle-BackColor="DarkBlue" HeaderStyle-ForeColor="White" Font-Italic="true" GridLines="Vertical" BorderColor="LightBlue" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-sqldatasource-example.html
Example 147
asp.net OnUpdated, SqlDataSourceStatusEventArgs example: using SqlDataSource <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void SqlDataSource1_Updated(object sender, SqlDataSourceStatusEventArgs e) { if (e.AffectedRows > 0) { Label1.Text = e.AffectedRows.ToString() + " row(s) updated successfully!"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net OnUpdated, SqlDataSourceStatusEventArgs example: using SqlDataSource</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">SqlDataSourceStatusEventArgs Example</h2> <asp:Label ID="Label1" runat="server" Font-Italic="true" ForeColor="Red"></asp:Label> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName FROM Products" UpdateCommand="Update Products SET ProductName=@ProductName WHERE ProductID=@ProductID" OnUpdated="SqlDataSource1_Updated" > </asp:SqlDataSource> <asp:DetailsView ID="DetailsView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="ProductID" AutoGenerateEditButton="true" AllowPaging="true" ForeColor="AliceBlue" BackColor="CornflowerBlue" BorderColor="LightBlue" > </asp:DetailsView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-onupdated-sqldatasourcestatuseve.html
Example 148
asp.net OnSelected, SqlDataSourceStatusEventArgs example: using SqlDataSource <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void SqlDataSource1_Selected(object sender, SqlDataSourceStatusEventArgs e) { Label1.Text = e.AffectedRows.ToString() + " row(s) selected!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net OnSelected, SqlDataSourceStatusEventArgs example: using SqlDataSource</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">SqlDataSource OnSelected Example</h2> <asp:Label ID="Label1" runat="server" Font-Italic="true" ForeColor="Red"></asp:Label> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="SELECT ProductID, ProductName, UnitPrice FROM Products" OnSelected="SqlDataSource1_Selected" > </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" ForeColor="AliceBlue" BackColor="CornflowerBlue" BorderColor="LightBlue" HeaderStyle-BackColor="DarkBlue" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/11/aspnet-onselected-sqldatasourcestatusev.html
Example 149
asp.net SqlDataSource example: DataSourceMode DataSet <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net SqlDataSource example: DataSourceMode DataSet</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">DataSourceMode DataSet Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" DataSourceMode="DataSet" SelectCommand="SELECT TOP 25 ProductID, ProductName, UnitPrice FROM Products" > </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Text="Sorting and Paging are enable <br /> in DataSourceMode DataSet" Font-Bold="true" ForeColor="IndianRed"> </asp:Label> <br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="true" PageSize="5" AllowSorting="true" BackColor="Snow" ForeColor="LightCoral" HeaderStyle-BackColor="HotPink" HeaderStyle-ForeColor="Snow" BorderColor="HotPink" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-sqldatasource-example_04.html
Example 150
asp.net SqlDataSource example: DataSourceMode DataReader <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>asp.net SqlDataSource example: DataSourceMode DataReader</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">DataSourceMode DataReader Example</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" DataSourceMode="DataReader" SelectCommand="SELECT TOP 4 ProductID, ProductName, UnitPrice FROM Products" > </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Text="Sorting and Paging are disable <br /> in DataSourceMode DataReader" Font-Bold="true" ForeColor="SandyBrown"> </asp:Label> <hr /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AllowPaging="false" AllowSorting="false" BackColor="Azure" ForeColor="Maroon" HeaderStyle-BackColor="Red" HeaderStyle-ForeColor="AntiqueWhite" > </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/aspnet-sqldatasource-example_5322.htmls
Example 151
How to handle null value parameters in SqlDataSource in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>How to handle null value parameters in SqlDataSource in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">SqlDataSource Control Example: handle null value parameters</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Font-Size="Larger" Text="Categories" > </asp:Label> <asp:DropDownList ID="DropDownList1" runat="server" BackColor="DodgerBlue" ForeColor="Snow" Font-Bold="true" Font-Italic="true" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID" AppendDataBoundItems="true" AutoPostBack="true" > <asp:ListItem Value="">Show All</asp:ListItem> </asp:DropDownList> <br /><br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select CategoryID, CategoryName From Categories" > </asp:SqlDataSource> <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, UnitPrice From Products Where CategoryID= IsNull(@CategoryID, CategoryID)" CancelSelectOnNullParameter="false" > <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="CategoryID" ConvertEmptyStringToNull="true" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AllowPaging="true" BackColor="Crimson" ForeColor="Snow" BorderColor="Snow" > <HeaderStyle BackColor="DodgerBlue" ForeColor="Snow" /> <Columns> <asp:BoundField DataField="ProductID" HeaderText="Product ID" ReadOnly="true" /> <asp:BoundField DataField="Productname" HeaderText="Product Name" /> <asp:BoundField DataField="UnitPrice" HeaderText="Unit Price" /> </Columns> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/08/how-to-handle-null-value-parameters-in.html
Example 152
Using CancelSelectOnNullParameter property in SqlDataSource in asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Using CancelSelectOnNullParameter property in SqlDataSource in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">SqlDataSource Example: using CancelSelectOnNullParameter Property</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select CategoryID, CategoryName From Categories" > </asp:SqlDataSource> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataValueField="CategoryID" DataTextField="CategoryName" AppendDataBoundItems="true" AutoPostBack="true" > <asp:ListItem Text="All" Value=""></asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From Products Where CategoryID=IsNull(@CategoryID, CategoryID)" SelectCommandType="Text" CancelSelectOnNullParameter="false" > <SelectParameters> <asp:ControlParameter Name="CategoryID" ControlID="DropDownList1" PropertyName="SelectedValue" ConvertEmptyStringToNull="true" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView
ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="true" AllowPaging="true" PageSize="10" BorderColor="Snow" Font-Names="Comic Sans MS" Width="650" > <HeaderStyle BackColor="DarkGoldenrod" BorderColor="PeachPuff" ForeColor="Snow" Height="45"/> <RowStyle BackColor="Chocolate" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="OrangeRed" Font-Bold="true" Font-Size="X-Large" ForeColor="Snow" /> <PagerSettings Mode="Numeric" /> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/10/using-cancelselectonnullparameter.html
Example 153
SqlDataSource - using DataSourceMode as DataReader in a asp.net <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>SqlDataSource - using DataSourceMode as DataReader in a asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon; font-style:italic;">SqlDataSource Example: using DataSourceMode as DataReader</h2> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommandType="Text" SelectCommand="Select categoryID, CategoryName From Categories" DataSourceMode="DataReader" > </asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Font-Size="Large" Font-Italic="true" Text="Select category" > </asp:Label> <asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataValueField="CategoryID" DataTextField="CategoryName" Font-Italic="true" AutoPostBack="true" ForeColor="Snow" BackColor="Crimson" Font-Size="Medium" Font-Bold="true" > </asp:DropDownList> <br /><br /> <asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, UnitPrice From Products Where CategoryID=@CategoryID" SelectCommandType="Text" > <SelectParameters> <asp:ControlParameter ControlID="DropDownList1" PropertyName="SelectedValue" Name="CategoryID" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="true" AllowPaging="true" PageSize="10" BorderColor="LightBlue" Font-Names="Comic Sans MS" Width="650" > <HeaderStyle BackColor="DodgerBlue" ForeColor="Snow" Height="45"/> <RowStyle BackColor="CornflowerBlue" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="DarkBlue" Font-Bold="true" Font-Size="X-Large" ForeColor="Snow" /> <PagerSettings Mode="Numeric" /> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/10/sqldatasource-using-datasourcemode-as.html
Example 154
How to delete records (data) using GridView and SqlDataSource <%@ Page Language="C#" AutoEventWireup="true" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e) { if (e.Exception == null) { if (e.AffectedRows == 1) { Label1.Text = "One Record deleted successfully!"; } else { Label1.Text = "An error occured!"; } } else { Label1.Text = "Error: " + e.Exception.Message; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>How to delete records (data) using GridView and SqlDataSource</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">SqlDataSource and GridView Example: Delete Records</h2> <!-- Remove relation between Products and OrderDetails tables for test this example --> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From products" SelectCommandType="Text" DeleteCommand="Delete From Products Where ProductID=@original_ProductID" OldValuesParameterFormatString="original_{0}" OnDeleted="SqlDataSource1_Deleted" > <SelectParameters> <asp:Parameter Direction="Output" Name="Count" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:Label ID="Label1" runat="server"
Font-Bold="true" Font-Italic="true" Font-Size="Large" ForeColor="Crimson" > </asp:Label> <br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="true" DataKeyNames="ProductID" AllowPaging="true" PageSize="8" BorderColor="Salmon" AutoGenerateDeleteButton="true" Font-Names="Comic Sans MS" Width="850" > <HeaderStyle BackColor="OrangeRed" ForeColor="Snow" Height="45"/> <RowStyle BackColor="DeepPink" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="BurlyWood" Font-Bold="true" Font-Size="X-Large" ForeColor="Snow" /> <PagerSettings Mode="Numeric" /> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/10/how-to-delete-records-data-using.html
Example 155
How to use OnDeleted event in SqlDataSource for deleting records <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> void SqlDataSource1_Deleted(object sender, SqlDataSourceStatusEventArgs e) { if (e.Exception == null) { if (e.AffectedRows == 1) { Label1.Text = "One Record deleted successfully!"; Label1.ForeColor = Color.Green; } else { Label1.Text = "An error occured!"; Label1.ForeColor = Color.Red; } } else { Label1.Text = "Error Details: " + e.Exception.Message; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>How to use OnDeleted event in SqlDataSource for deleting records</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy; font-style:italic;">SqlDataSource Example: Using OnDeleted Events</h2> <!-- Remove relation between Products and OrderDetails tables for test this example --> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName, QuantityPerUnit, UnitPrice From products" SelectCommandType="Text" DeleteCommand="Delete From Products Where ProductID=@original_ProductID" OldValuesParameterFormatString="original_{0}" OnDeleted="SqlDataSource1_Deleted" > <SelectParameters> <asp:Parameter Direction="Output" Name="Count" Type="Int32" /> </SelectParameters>
</asp:SqlDataSource> <asp:Label ID="Label1" runat="server" Font-Bold="true" Font-Italic="true" Font-Size="Large" ForeColor="SeaGreen" > </asp:Label> <br /><br /> <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" DataKeyNames="ProductID" AllowPaging="true" PageSize="8" BorderColor="Salmon" AutoGenerateDeleteButton="true" Font-Names="Comic Sans MS" Width="850" > <HeaderStyle BackColor="Crimson" ForeColor="Snow" Height="45"/> <RowStyle BackColor="OrangeRed" ForeColor="Snow" Font-Italic="true" /> <PagerStyle Height="45" HorizontalAlign="Right" BackColor="BurlyWood" Font-Bold="true" Font-Size="X-Large" ForeColor="Snow" /> <PagerSettings Mode="Numeric" /> <Columns> <asp:BoundField HeaderText="Product ID" DataField="ProductID" /> <asp:BoundField HeaderText="Product Name" DataField="ProductName" /> <asp:BoundField HeaderText="Quantity Per Unit" DataField="QuantityPerUnit" /> <asp:BoundField HeaderText="Unit Price" DataField="UnitPrice"/> </Columns> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/10/how-to-use-ondeleted-event-in.html
Example 156
SqlParameter example: how to use SqlParameter in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { SqlConnection MyConnection; SqlCommand MyCommand; SqlDataReader MyReader; SqlParameter ProductNameParam; MyConnection = new SqlConnection(); MyConnection.ConnectionString = ConfigurationManager.ConnectionStrings["AppConnectionString1"].ConnectionString; MyCommand = new SqlCommand(); MyCommand.CommandText = "SELECT * FROM PRODUCTS WHERE PRODUCTNAME = @PRODUCTNAME"; MyCommand.CommandType = CommandType.Text; MyCommand.Connection = MyConnection; ProductNameParam = new SqlParameter(); ProductNameParam.ParameterName = "@PRODUCTNAME"; ProductNameParam.SqlDbType = SqlDbType.VarChar; ProductNameParam.Size = 25; ProductNameParam.Direction = ParameterDirection.Input; ProductNameParam.Value = "CHAI"; MyCommand.Parameters.Add(ProductNameParam); MyCommand.Connection.Open(); MyReader = MyCommand.ExecuteReader(CommandBehavior.CloseConnection); GridView1.DataSource = MyReader; GridView1.DataBind(); MyCommand.Dispose(); MyConnection.Dispose(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>SqlParameter example: how to use SqlParameter in asp.net</title> </head> <body> <form id="form1" runat="server"> <div>
<asp:GridView ID="GridView1" runat="server"> </asp:GridView> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/sqlparameter-example-how-to-use.html
Example 157
How to convert number (numeric value) to string (ToString) in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int myNumber = 20; string myString = myNumber.ToString(); Label1.Text = "MyNumber: " + myNumber; Label1.Text += "<br />Number now converted to string: " + myString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to convert number (numeric value) to string (ToString) in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net example: ToString()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Convert Number To String" ForeColor="Red" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-convert-number-numeric-value-to.html
Example 158
How to convert string to numeric value (number ToInt32) in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string testString = "55"; int testNumber = Convert.ToInt32(testString); int sum = testNumber + 5; Label1.Text = "Test String: " + testString; Label1.Text += "<br />Test String now converted to number[Int32]: " + testNumber; Label1.Text += "<br />Test Number+5[after convert]: " + sum; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to convert string to numeric value (number ToInt32) in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">asp.net example: ToInt32()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DodgerBlue" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Convert String To Number" ForeColor="DarkBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-convert-string-to-numeric-value.html
Example 159
asp.net Int32.Parse() method example: How to convert string to numeric value <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { string sampleString = "100"; int sampleNumber = Int32.Parse(sampleString); int sum = sampleNumber + 10; Label1.Text = "Sample String: " + sampleString; Label1.Text += "<br />Sample String now converted to number[Int32]: " + sampleNumber; Label1.Text += "<br />Sample Number+10[after convert]: " + sum; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>asp.net Int32.Parse() method example: How to convert string to numeric value</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Fuchsia">asp.net example: Int32.Parse()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Convert String To Number Using Int32.Parse()" ForeColor="IndianRed" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/aspnet-int32parse-method-example-how-to.html
Example 160
How to add specific character at the start (left) position of a string in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Jones"; } } protected void Button1_Click(object sender, System.EventArgs e) { string testString = TextBox1.Text.ToString(); string padLeft = testString.PadLeft(10, '@'); TextBox1.Text = padLeft; Label1.Text = "Required @ added successfully at the strat of test string"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to add specific character at the start (left) position of a string in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Purple">asp.net string example: PadLeft()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Sample String" ForeColor="Crimson" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Crimson" ForeColor="Snow" >
</asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Add @ start of string" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-add-specific-character-at-start.html
Example 161
How to get substring from a string in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Jones is here."; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); string subString = myString.Substring(0,5); Label1.Text = "Substring[0,5]: " + subString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get substring from a string in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net string example: Substring()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Firebrick" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="Purple" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="Purple" ForeColor="Snow" > </asp:TextBox> <br /><br /> <asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Get Substring [0,5]" ForeColor="Purple" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-substring-from-string-in.html
Example 162
How to replace a specified substring with another string in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "This is a sample string."; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); string replaceString = myString.Replace("sample","test"); Label1.Text = "String replaced successfully [sample with test]!"; TextBox1.Text = replaceString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to replace a specified substring with another string in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Maroon">asp.net string example: Replace()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Red" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="DarkSlateBlue" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkSlateBlue" ForeColor="AliceBlue" > </asp:TextBox>
<br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Replace sample With test" ForeColor="DarkSlateBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-replace-specified-substring-with.html
Example 163
How to insert a string inside a string at a specified index position in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "I am Jones."; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); string modifiedString = myString.Insert(0,"Hi! "); Label1.Text = "String inserted successfully!"; TextBox1.Text = modifiedString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to insert a string inside a string at a specified index position in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net string example: Insert()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Maroon" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="DarkGreen" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkSeaGreen" ForeColor="DarkGreen" > </asp:TextBox>
<br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Insert String [0,Hi!]" ForeColor="DarkGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-insert-string-inside-string-at.html
Example 164
How to split a string with specific delimiter and populate an array in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Red.Green.Blue.HotPink.Pink"; TextBox1.Width = 250; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); char[] separator = new char[] {'.'}; string[] colorList = myString.Split(separator); ListBox1.DataSource = colorList; ListBox1.DataBind(); ListBox1.Height = 100; Label1.Text = "String split and populate ListBox successfully!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to split a string with specific delimiter and populate an array in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Teal">asp.net string example: Split</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="DodgerBlue" ForeColor="AliceBlue" > </asp:ListBox> <br /><br /> <asp:Label ID="Label2" runat="server"
Text="Test String" ForeColor="DarkGreen" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkSeaGreen" ForeColor="DarkGreen" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Split String And Populate ListBox" ForeColor="DarkGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-split-string-with-specific.html
Example 165
How to get whether a string starts (begin) with specific substring in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Hi! I am Jenny Jones."; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); bool startsWith = myString.StartsWith("Hi"); Label1.Text = "Is the string start with [Hi]?: " + startsWith; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get whether a string starts (begin) with specific substring in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net string example: StartsWith()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="DarkGreen" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="MediumSeaGreen" ForeColor="AliceBlue" > </asp:TextBox> <br /><br /> <asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="String StartsWith [Hi]?" ForeColor="MediumPurple" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-whether-string-starts-begin.htmls
Example 166
How to get whether a string ends with specific substring in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Jones say hello!"; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); bool endsWith = myString.EndsWith("Jenny"); Label1.Text = "Is the string ends with [Jenny]?: " + endsWith; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to get whether a string ends with specific substring in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Navy">asp.net string example: EndsWith()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="OrangeRed" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="Purple" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="MediumPurple" ForeColor="AliceBlue" > </asp:TextBox> <br /><br /> <asp:Button
ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="String EndsWith [Jenny]?" ForeColor="MediumBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-get-whether-string-ends-with.html
Example 167
How to find the first index position of a substring in a string <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "Red, SeaGreen, Green, Pink, HotPink"; TextBox1.Width = 250; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); int indexOf = myString.IndexOf("Green",0); Label1.Text = "IndexOf [Green] in the String: " + indexOf; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to find the first index position of a substring in a string</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Purple">asp.net string example: IndexOf()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="HotPink" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="DarkGreen" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="SeaGreen" ForeColor="AliceBlue" > </asp:TextBox> <br /><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Find First Index Position OF [Green]" ForeColor="SeaGreen" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-find-first-index-position-of.html
Example 168
How to remove a specified number of strings from a specified position in a string <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "This is a test String."; } } protected void Button1_Click(object sender, System.EventArgs e) { string myString = TextBox1.Text.ToString(); string stringAfterRemove = myString.Remove(10, 5); TextBox1.Text = stringAfterRemove; Label1.Text = "Substring remove successfully [10,5]!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to remove a specified number of strings from a specified position in a string</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net string example: Remove()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String" ForeColor="Red" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue" > </asp:TextBox> <br /><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Remove Substring [10,5]" ForeColor="HotPink" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-remove-specified-number-of.html
Example 169
How to join an array of strings (elements) into a new string with specific separator <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> private string[] colorArray = { "Red", "Green", "Yellow", "HotPink", "SeaGreen" }; protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { ListBox1.DataSource = colorArray; ListBox1.DataBind(); } } protected void Button1_Click(object sender, System.EventArgs e) { string testString = string.Join(", ", colorArray); Label1.Text = "Joined successfully: " + testString; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to join an array of strings (elements) into a new string with specific separator</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net string example: Join()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Crimson" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" ForeColor="DodgerBlue" Font-Bold="true" Text="ListBox populated by an array" > </asp:Label> <br /> <asp:ListBox ID="ListBox1" runat="server" BackColor="DodgerBlue"
ForeColor="Snow" > </asp:ListBox> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Join array elements and build String" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-join-array-of-strings-elements.html
Example 170
How to compare two string (case sensitive) <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void page_Load(object sender, System.EventArgs e) { if(!this.IsPostBack) { TextBox1.Text = "apple."; TextBox2.Text = "Apple."; } } protected void Button1_Click(object sender, System.EventArgs e) { string testString1 = TextBox1.Text.ToString(); string testString2 = TextBox2.Text.ToString(); int result = string.Compare(testString1, testString2); Label1.Text = ""; if(result == 0) { Label1.Text += "Two strings are equal"; } else if(result == -1) { Label1.Text += "Test String1 is less than Test String2"; } else if(result == 1) { Label1.Text += "Test String1 is greater than Test String2"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to compare two string (case sensitive)</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">asp.net string example: Compare()</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="SeaGreen" Font-Bold="true" Font-Italic="true" > </asp:Label>
<br /><br /> <asp:Label ID="Label2" runat="server" Text="Test String1" ForeColor="Red" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue" > </asp:TextBox> <br /> <asp:Label ID="Label3" runat="server" Text="Test String2" ForeColor="Red" > </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="OrangeRed" ForeColor="AliceBlue" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Text="Compare" ForeColor="Crimson" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/01/how-to-compare-two-string-in-aspnet.html
Example 171
How to add cell and column in a table programmatically <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { int rows = Int32.Parse(TextBox1.Text); int columns = Int32.Parse(TextBox2.Text); for (int row = 0; row < rows; row++ ) { TableRow newRow = new TableRow(); Table1.Controls.Add(newRow); for (int column = 0; column < columns; column++ ) { TableCell newCell = new TableCell(); newCell.Text = "Cell" + row.ToString(); newCell.Text += "; Column" + column.ToString(); newCell.BorderStyle = BorderStyle.Solid; newCell.BorderWidth = Unit.Pixel(1); newCell.BorderColor = System.Drawing.Color.DodgerBlue; newRow.Controls.Add(newCell); } } } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>How to add cell and column in a table programmatically</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green">Table: Programmatically add Cell and Column</h2> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="HotPink" Text="Rows" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="HotPink" ForeColor="FloralWhite" > </asp:TextBox> <br /> <asp:Label ID="Label2" runat="server"
Font-Bold="true" ForeColor="HotPink" Text="Columns" > </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="HotPink" ForeColor="FloralWhite" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="HotPink" OnClick="Button1_Click" Text="Create Table" /> <br /><br /> <asp:Table ID="Table1" runat="server" BorderWidth="1" BorderColor="DodgerBlue" > </asp:Table> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/02/how-to-add-cell-and-column-in-table.html
Example 172
How to use OnTextChanged event in TextBox <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void TextBox1_TextChanged(object sender, System.EventArgs e) { TextBox2.Text = TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>How to use OnTextChanged event in TextBox</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Red">TextBox Example: OnTextChanged</h2> <asp:Label ID="Label1" runat="server" Text="Email" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" AutoPostBack="true" OnTextChanged="TextBox1_TextChanged" > </asp:TextBox> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Confirm Email" > </asp:Label> <asp:TextBox ID="TextBox2" runat="server" BackColor="LightGoldenrodYellow" ForeColor="Crimson" > </asp:TextBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/03/how-to-use-ontextchanged-event-in.html
Example 173
Validation example: how to disable client script <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Your City: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Validation example: how to disable client script</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkBlue"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="City Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Input City Name!" EnableClientScript="false" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit City" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/validation-example-how-to-disable.html
Example 174
Validation example: using SetFocusOnError property in validation control <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Your Country: " + TextBox1.Text.ToString() + "<br />City: " + TextBox2.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Validation example: using SetFocusOnError property in validation control</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkTurquoise"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Country Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Input Country Name!" SetFocusOnError="true" > </asp:RequiredFieldValidator> <br /> <asp:Label ID="Label3" runat="server" Text="City Name" AssociatedControlID="TextBox2"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage="Input City Name!" SetFocusOnError="true" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /> </div>
</form> </body> </html> http://asp-net-example.blogspot.com/2008/10/validation-example-using.html
Example 175
Validation example: how to use Image for error alert <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Your Country: " + TextBox1.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Validation example: how to use Image for error alert</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="DarkOliveGreen"></asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Country Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage='<img src="ErrorImage.jpg">' > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit Country" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/validation-example-how-to-use-image-for.html
Example 176
ValidationSummary example: how to use ValidationSummary control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "Your Country: " + TextBox1.Text.ToString() + "<br />Region: " + TextBox2.Text.ToString() + "<br />City: " + TextBox3.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>ValidationSummary example: how to use ValidationSummary control in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="BlueViolet"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Country Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage='Input Country!' EnableClientScript="true" SetFocusOnError="true" Text="*" > </asp:RequiredFieldValidator> <br /> <asp:Label ID="Label3" runat="server" Text="Region Name" AssociatedControlID="TextBox2"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2" ErrorMessage='Input Region!' EnableClientScript="true" SetFocusOnError="true" Text="*"
> </asp:RequiredFieldValidator> <br /> <asp:Label ID="Label4" runat="server" Text="City Name" AssociatedControlID="TextBox3"></asp:Label> <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="TextBox3" ErrorMessage='Input Region!' EnableClientScript="true" SetFocusOnError="true" Text="*" > </asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" /> <br /><br /> <asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="Following error occurs:" ShowMessageBox="false" DisplayMode="BulletList" ShowSummary="true" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/validationsummary-example-how-to-use.html
Example 177
Using Button control with CausesValidation property in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You submited this name: " + TextBox1.Text.ToString(); } protected void Button2_Click(object sender, System.EventArgs e) { Label1.Text = "You clicked the cancel button."; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Using Button control with CausesValidation property in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Fuchsia">Using CausesValidation property</h2> <asp:Label ID="Label1" runat="server" Font-Size="Large" ForeColor="Teal"></asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Input name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Name required!"></asp:RequiredFieldValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit name" OnClick="Button1_Click" Font-Bold="true" CausesValidation="true" /> <asp:Button ID="Button2" runat="server" Text="Cancel" OnClick="Button2_Click" Font-Bold="true" ForeColor="Red" CausesValidation="false" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/12/using-button-control-with.html
Example 178
Wizard example: how to use Wizard control in asp.net <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void WizardStep4_Activate(object sender, System.EventArgs e) { Label5.Text = "Your Name: " + TextBox1.Text.ToString() + "<br />City: " + TextBox2.Text.ToString() + "<br />Favorite Color: " + RadioButtonList1.SelectedItem.Text.ToString() + "<br />Favorite Tool: " + RadioButtonList2.SelectedItem.Text.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Wizard Control Simple Example</title> </head> <body> <form id="form1" runat="server"> <div> <asp:Wizard ID="Wizard1" runat="server" HeaderText="Simple Example of Wizard Control" HeaderStyle-Font-Size="Larger" HeaderStyle-ForeColor="Crimson"> <WizardSteps> <asp:WizardStep ID="WizadStep1" runat="server" title="Personal Information"> <asp:Label ID="Label1" runat="server" Text="Your Name" AssociatedControlID="TextBox1"></asp:Label> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <br /> <asp:Label ID="Label2" runat="server" Text="City" AssociatedControlID="TextBox2"></asp:Label> <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox> </asp:WizardStep> <asp:WizardStep ID="WizardStep2" runat="server" title="Favorite Color?"> <asp:Label ID="Label3" runat="server" Text="Favorite Color?" AssociatedControlID="RadioButtonList1"></asp:Label> <asp:RadioButtonList ID="RadioButtonList1" runat="server"> <asp:ListItem Selected="True">Red</asp:ListItem> <asp:ListItem>Green</asp:ListItem> <asp:ListItem>Blue</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> <asp:WizardStep ID="WizardStep3" runat="server" title="Favorite Tool?"> <asp:Label ID="Label4" runat="server" Text="Most Favorite?" AssociatedControlID="RadioButtonList2"></asp:Label> <asp:RadioButtonList ID="RadioButtonList2" runat="server"> <asp:ListItem Selected="True">Asp.Net</asp:ListItem> <asp:ListItem>ColdFusion</asp:ListItem>
<asp:ListItem>PHP</asp:ListItem> </asp:RadioButtonList> </asp:WizardStep> <asp:WizardStep ID="WizardStep4" runat="server" Title="Result" OnActivate="WizardStep4_Activate"> <asp:Label ID="Label5" runat="server" Font-Size="X-Large" ForeColor="DarkGoldenrod"></asp:Label> </asp:WizardStep> </WizardSteps> </asp:Wizard> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2008/10/wizard-example-how-to-use-wizard.html
Example 179
Ajax ScriptManager - How to use ScriptManager in asp.net ajax <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, System.EventArgs e) { Label1.Text = "You clicked Button1 at:" + DateTime.Now.ToLongTimeString(); Label1.ForeColor = System.Drawing.Color.Red; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Ajax ScriptManager - How to use ScriptManager in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax ScriptManager Example: How To Use ScriptManager</h2> <hr width="550" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <br /> <asp:Label ID="Label1" runat="server" ForeColor="RosyBrown" Font-Size="X-Large" Text="This is a Label control for test Ajax feature" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Get Button Click Time Using Ajax" OnClick="Button1_Click" Font-Bold="true" ForeColor="DarkBlue" Height="45" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-scriptmanager-how-to-use.html
Example 180
Ajax Timer - How to use Timer in asp.net ajax <%@ Page Language="C#" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Web.Configuration" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { GridView1.DataSourceID = "SqlDataSource1"; GridView1.DataBind(); GridView1.SelectedIndex = 0; } } protected void Timer1_Tick(object sender, System.EventArgs e) { int selectedRow = GridView1.SelectedIndex; GridView1.SelectedIndex = selectedRow + 1; if (selectedRow == 9) { GridView1.SelectedIndex = 0; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Button clicked but GridView SelectedIndex not reset"; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Timer - How to use Timer in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Timer Example: How To Use Timer In ASP.NET Ajax</h2> <hr width="550" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" DataSourceMode="DataReader" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select Top 9 ProductID, ProductName, UnitPrice From Products" >
</asp:SqlDataSource> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:GridView ID="GridView1" runat="server" ForeColor="Snow" BackColor="OrangeRed" BorderColor="Orange" Font-Names="Comic Sans MS" Width="550" > <SelectedRowStyle ForeColor="Snow" BackColor="Orange" Height="35" Font-Italic="true" /> <HeaderStyle BackColor="IndianRed" Height="40" /> </asp:GridView> <asp:Timer ID="Timer1" runat="server" Interval="2000" OnTick="Timer1_Tick" > </asp:Timer> <br /> <asp:Label ID="Label1" runat="server" Text="Test Label" ForeColor="DodgerBlue" Font-Size="Medium" Font-Names="Comic Sans MS" > </asp:Label> <br /><br /> <asp:Button runat="server" ID="Button1" Text="Click me after 5 seconds" OnClick="Button1_Click" Font-Bold="true" ForeColor="SeaGreen" Height="45" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-timer-how-to-use-timer-in-aspnet.html
Example 181
Ajax UpdatePanel - How to use UpdatePanel in asp.net ajax <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { Label1.Text = "0"; } } protected void Timer1_Tick(object sender, System.EventArgs e) { int counter = Convert.ToInt32(Label1.Text); counter = counter + 1; Label1.Text = counter.ToString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax UpdatePanel - How to use UpdatePanel in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax UpdatePanel Example: How To Use UpdatePanel</h2> <hr width="550" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick" > </asp:Timer> <br /> <asp:Label ID="Label1" runat="server" Text="Test Label" ForeColor="DeepPink" Font-Size="XX-Large" Font-Names="Comic Sans MS" Font-Bold="true" > </asp:Label>
</ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-updatepanel-how-to-use-updatepanel.html
Example 182
Ajax ContentTemplate - How to use ContentTemplate in asp.net ajax <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <%@ Import Namespace="System.Drawing.Text" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> string[] colorArray = {"DeepPink", "DeepSkyBlue", "Fuchsia", "Green", "LightBlue", "Maroon", "Navy", "Orchid", "Peru", "Plum", "Red"}; protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { Label1.Text = colorArray[0]; Label1.ForeColor = Color.FromName(Label1.Text); } } protected void Timer1_Tick(object sender, EventArgs e) { int indexOf = Array.IndexOf(colorArray,Label1.Text); int nextIndex = indexOf+1; if (nextIndex > colorArray.Length) { Label1.ForeColor = Color.FromName(colorArray[0]); Label1.Text = colorArray[0].ToString(); } else { Label1.ForeColor = Color.FromName(colorArray[nextIndex]); Label1.Text = colorArray[nextIndex].ToString(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ContentTemplate - How to use ContentTemplate in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax ContentTemplate Example: How To Use ContentTemplate</h2> <hr width="550" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Timer
ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="2000" > </asp:Timer> <asp:Label ID="Label1" runat="server" ForeColor="DeepPink" Font-Size="XX-Large" Font-Names="Comic Sans MS" Font-Bold="true" > </asp:Label> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-contenttemplate-how-to-use.html
Example 183
Ajax AsyncPostBackTrigger - How to use AsyncPostBackTrigger in asp.net ajax Triggers <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); } protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { Label2.ForeColor = Color.FromName(RadioButtonList1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax AsyncPostBackTrigger - How to use AsyncPostBackTrigger in asp.net ajax Triggers</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Crimson; font-style:italic;">Ajax Triggers Example: Using AsyncPostBackTrigger</h2> <hr width="450" align="left" color="Salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:Label ID="Label1" runat="server" ForeColor="SeaGreen" Font-Size="Medium" Font-Bold="true" > </asp:Label> <br /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label2" runat="server" Text="Select RadioButton for change Label color." Font-Bold="true" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large" > </asp:Label> </ContentTemplate>
<Triggers> <asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <br /><br /> <asp:RadioButtonList ID="RadioButtonList1" runat="server" ForeColor="DarkSeaGreen" BorderColor="LawnGreen" BorderWidth="1" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true" RepeatColumns="3" > <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>RosyBrown</asp:ListItem> <asp:ListItem>DarkSeaGreen</asp:ListItem> <asp:ListItem>DodgerBlue</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DarkSalmon</asp:ListItem> <asp:ListItem>Cyan</asp:ListItem> <asp:ListItem>CornFlowerBlue</asp:ListItem> </asp:RadioButtonList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-asyncpostbacktrigger-how-to-use.html
Example 184
Ajax UpdatePanel - How to use multiple UpdatePanel in asp.net ajax <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); } protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { Label2.ForeColor = Color.FromName(ListBox1.SelectedItem.Text); Label3.ForeColor = Color.FromName(ListBox1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax UpdatePanel - How to use multiple UpdatePanel in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OrangeRed; font-style:italic;">Ajax UpdatePanel Example: Using Multiple UpdatePanel</h2> <hr width="450" align="left" color="Salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:Label ID="Label1" runat="server" ForeColor="DodgerBlue" Font-Size="Medium" Font-Bold="true" > </asp:Label> <br /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label2" runat="server" Text="This Label2 and Triggers both are under UpdatePanel1" Font-Bold="true" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large" > </asp:Label> </ContentTemplate>
<Triggers> <asp:AsyncPostBackTrigger ControlID="ListBox1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:Label ID="Label3" runat="server" Font-Bold="true" Font-Size="Large" Text="This is Label3 which is under UpdatePanel2" > </asp:Label> </ContentTemplate> </asp:UpdatePanel> <br /><br /> <asp:ListBox ID="ListBox1" runat="server" ForeColor="DarkSeaGreen" Width="200" SelectionMode="Single" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" Height="150" Font-Bold="true" > <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> <asp:ListItem>DarkSeaGreen</asp:ListItem> <asp:ListItem>Orange</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DarkSalmon</asp:ListItem> <asp:ListItem>OrangeRed</asp:ListItem> <asp:ListItem>CornFlowerBlue</asp:ListItem> </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-updatepanel-how-to-use-multiple.html
Example 185
Ajax Triggers - How to use Triggers in asp.net ajax UpdatePanel <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { ListBox1.ForeColor = System.Drawing.Color.DodgerBlue; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Triggers - How to use Triggers in asp.net ajax UpdatePanel</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SeaGreen; font-style:italic;">Ajax Triggers Example: How To Use Triggers</h2> <hr width="450" align="left" color="DarkSeaGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ListBox ID="ListBox1" runat="server" ForeColor="Crimson" BackColor="Snow" Font-Bold="true" Font-Italic="true" Font-Size="X-Large" Font-Names="Comic Sans MS" Width="250" > <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>SeaGreen</asp:ListItem> <asp:ListItem>DarkSeaGreen</asp:ListItem> <asp:ListItem>DodgerBlue</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DarkSalmon</asp:ListItem> <asp:ListItem>Cyan</asp:ListItem> <asp:ListItem>Red</asp:ListItem> </asp:ListBox> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" /> </Triggers> </asp:UpdatePanel>
<br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" Font-Bold="true" Text="Change ListBox Text Color" OnClick="Button1_Click" Height="45" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-triggers-how-to-use-triggers-in.html
Example 186
Ajax UpdatePanel - How to use UpdateMode Conditional in asp.net ajax <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToLongTimeString(); } protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e) { Panel1.BackColor = Color.FromName(ListBox1.SelectedItem.Text); Panel2.BackColor = Color.FromName(ListBox1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax UpdatePanel - How to use UpdateMode Conditional in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax UpdatePanel Example: Using UpdateMode Conditional</h2> <hr width="550" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Medium" Font-Bold="true" > </asp:Label> <br /><br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel1" runat="server" BorderWidth="1" Height="50" Width="450" BackColor="SeaGreen" ForeColor="Snow" HorizontalAlign="Center" Font-Bold="true"
> Panel1 and Triggers both are under UpdatePanel1. </asp:Panel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ListBox1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> <br /> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Panel ID="Panel2" runat="server" BorderWidth="1" Height="50" Width="450" BackColor="SeaGreen" ForeColor="Snow" HorizontalAlign="Center" Font-Bold="true" > This is Panel2 and it is under UpdatePanel2. </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <br /><br /> <asp:ListBox ID="ListBox1" runat="server" ForeColor="DeepPink" Width="200" SelectionMode="Single" Font-Italic="true" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged" Height="150" Font-Bold="true" Font-Size="Large" Font-Names="Comic Sans MS" > <asp:ListItem>SaddleBrown</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> <asp:ListItem>IndianRed</asp:ListItem> <asp:ListItem>Orange</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DarkSalmon</asp:ListItem> <asp:ListItem>OrangeRed</asp:ListItem> <asp:ListItem>CornFlowerBlue</asp:ListItem> </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-updatepanel-how-to-use-updatemode.html
Example 187
Ajax ProgressTemplate DisplayAfter attribute - How to use in asp.net <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Label2.ForeColor = Color.OrangeRed; Label2.Font.Name = "Comic Sans MS"; Label2.Font.Size = FontUnit.Large; Label2.Font.Italic = true; Label2.Font.Bold = true; } } protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(6000); Label2.Text = "[System Time] " + DateTime.Now.ToLongTimeString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ProgressTemplate DisplayAfter attribute - How to use in asp.net</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SaddleBrown; font-style:italic;">Ajax UpdateProgress Example: Using DisplayAfter Attribute</h2> <hr width="550" align="left" color="Tan" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server" DisplayAfter="3000"> <ProgressTemplate> <asp:Label ID="Label1" runat="server" ForeColor="DeepPink" Font-Bold="true" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Medium" Text="Please wait page updating....." > </asp:Label> </ProgressTemplate>
</asp:UpdateProgress> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label2" runat="server" > </asp:Label> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Height="45" Text="Get System Time" ForeColor="DodgerBlue" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-progresstemplate-displayafter.html
Example 188
Ajax ProgressTemplate - How to use ProgressTemplate in asp.net ajax UpdateProgress <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BulletedList1.Width = 500; BulletedList1.BackColor = Color.AliceBlue; BulletedList1.Font.Bold = true; BulletedList1.Font.Size = FontUnit.Medium; } } protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); BulletedList1.Items.Add(DateTime.Now.ToLongTimeString()); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ProgressTemplate - How to use ProgressTemplate in asp.net ajax UpdateProgress</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax UpdateProgress Example: Using ProgressTemplate</h2> <hr width="550" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Bold="true" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large" Text="Please wait page updating....." > </asp:Label> </ProgressTemplate> </asp:UpdateProgress> <br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:BulletedList ID="BulletedList1" runat="server" ForeColor="DarkSeaGreen" BulletStyle="LowerAlpha" BorderColor="LawnGreen" BorderWidth="1" > </asp:BulletedList> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Height="45" Text="Get Button Click System Time" ForeColor="DodgerBlue" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-progresstemplate-how-to-use.html
Example 189
Ajax UpdateProgress - How to use UpdateProgress in asp.net ajax <%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(4000); RadioButtonList1.Items.Add(System.DateTime.Now.ToLongTimeString()); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax UpdateProgress - How to use UpdateProgress in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax UpdateProgress Example: Using UpdateProgress</h2> <hr width="550" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> <asp:Label ID="Label1" runat="server" Font-Bold="true" ForeColor="DodgerBlue" Font-Size="Medium" Text="please wait page updating...." > </asp:Label> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:RadioButtonList ID="RadioButtonList1" runat="server" ForeColor="OrangeRed" BackColor="Snow" BorderColor="Crimson" Font-Bold="true" BorderWidth="1" Width="450" RepeatColumns="2" > </asp:RadioButtonList>
<br /> <asp:Button ID="Button1" runat="server" Text="Add Button Click Time In RadioButtonList" OnClick="Button1_Click" Height="42" Font-Bold="true" ForeColor="DarkBlue" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-updateprogress-how-to-use.html
Example 190
Ajax UpdateProgress image - How to use image in UpdateProgress in asp.net ajax <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckBoxList1.ForeColor = Color.SeaGreen; CheckBoxList1.BackColor = Color.LawnGreen; CheckBoxList1.Font.Bold = true; CheckBoxList1.Font.Size = FontUnit.Medium; CheckBoxList1.BorderColor = Color.MediumSeaGreen; CheckBoxList1.BorderWidth = 1; CheckBoxList1.Width = 450; CheckBoxList1.RepeatColumns = 2; } } protected void Button1_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(5000); CheckBoxList1.Items.Add(DateTime.Now.ToLongTimeString()); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax UpdateProgress image - How to use image in UpdateProgress in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Crimson; font-style:italic;">Ajax UpdateProgress Example: Using Image</h2> <hr width="450" align="left" color="LightPink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdateProgress ID="UpdateProgress1" runat="server"> <ProgressTemplate> <asp:Panel ID="Pnael1" runat="server" Width="450" HorizontalAlign="Center" > <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/ProgressImage.gif"
/> </asp:Panel> </ProgressTemplate> </asp:UpdateProgress> <br /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:CheckBoxList ID="CheckBoxList1" runat="server" > </asp:CheckBoxList> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Font-Bold="true" Height="45" Text="Add Button Click Time In CheckBoxList" ForeColor="DodgerBlue" /> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-updateprogress-image-how-to-use.html
Example 191
Ajax Timer OnTick event - How to use OnTick event in Timer control <%@ Page Language="C#" %> <%@ Import Namespace="System.Drawing" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { RadioButtonList1.Font.Name = "Comic Sans MS"; RadioButtonList1.Font.Size = FontUnit.Medium; RadioButtonList1.SelectedIndex = 0; RadioButtonList1.ForeColor = Color.FromName(RadioButtonList1.SelectedItem.Text); } } protected void Timer1_Tick(object sender, System.EventArgs e) { int selectedIndex = RadioButtonList1.SelectedIndex; int totalIndex = RadioButtonList1.Items.Count -1; if (selectedIndex == totalIndex) { RadioButtonList1.SelectedIndex = 0; } else { RadioButtonList1.SelectedIndex = selectedIndex + 1; } RadioButtonList1.ForeColor = Color.FromName(RadioButtonList1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Timer OnTick event - How to use OnTick event in Timer control</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Timer Example: How To Use OnTick Event</h2> <hr width="450" align="left" color="CornFlowerBlue" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:RadioButtonList ID="RadioButtonList1"
runat="server" BorderColor="Salmon" BorderWidth="1" RepeatColumns="3" > <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>RosyBrown</asp:ListItem> <asp:ListItem>IndianRed</asp:ListItem> <asp:ListItem>Maroon</asp:ListItem> <asp:ListItem>DodgerBlue</asp:ListItem> <asp:ListItem>SeaGreen</asp:ListItem> </asp:RadioButtonList> <asp:Timer ID="Timer1" runat="server" Interval="4000" OnTick="Timer1_Tick" > </asp:Timer> </ContentTemplate> </asp:UpdatePanel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-timer-ontick-event-how-to-use.html
Example 192
Ajax PagingBulletedListExtender - How to use PagingBulletedListExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax PagingBulletedListExtender - How to use PagingBulletedListExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control ToolKit Example: PagingBulletedListExtender</h2> <hr width="575" align="left" color="CornFlowerBlue" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:PagingBulletedListExtender ID="PagingBulletedListExtender1" runat="server" TargetControlID="BulletedList1" > </cc1:PagingBulletedListExtender> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select ProductID, ProductName From Products" > </asp:SqlDataSource> <asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="ProductName" DataValueField="ProductID" ForeColor="DodgerBlue" > </asp:BulletedList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-pagingbulletedlistextender-how-to.html
Example 193
Ajax ResizableControlExtender - How to use ResizableControlExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Image1.ImageUrl = "~/Images/RedForest.jpg"; Panel1.BorderColor = Color.DeepPink; Panel1.BorderWidth = 2; Panel1.HorizontalAlign = HorizontalAlign.Center; Panel1.BackColor = Color.Salmon; Panel1.Width = 450; Panel1.Height = 325; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ResizableControlExtender - How to use ResizableControlExtender in asp.net ajax</title> <style type="text/css"> .HandleCSS { width:20px; height:20px; background-color:Red; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax Control Toolkit Example: Using ResizableControlExtender</h2> <hr width="600" align="left" color="CornFlowerBlue" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:ResizableControlExtender ID="ReasizableControlExtender1" runat="server" TargetControlID="Panel1" HandleCssClass="HandleCSS" >
</cc1:ResizableControlExtender> <asp:Panel ID="Panel1" runat="server" > <br /> <asp:Image ID="Image1" runat="server" /> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-resizablecontrolextender-how-to.html
Example 194
Ajax TabContainer and TabPanel - How to use TabContainer in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { Image1.ImageUrl = "~/Images/RedFlower.jpg"; Image2.ImageUrl = "~/Images/Sky.jpg"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax TabContainer and TabPanel - How to use TabContainer in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using TabContainer</h2> <hr width="500" align="left" color="CornFlowerBlue" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:TabContainer ID="TabContainer1" runat="server" Width="600"> <cc1:TabPanel ID="TabPanel1" runat="server"> <HeaderTemplate> Red Flower </HeaderTemplate> <ContentTemplate> <asp:Image ID="Image1" runat="server" /> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel2" runat="server"> <HeaderTemplate> Color List </HeaderTemplate> <ContentTemplate> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BorderColor="DeepPink" ForeColor="Snow" BackColor="Crimson"
BorderWidth="1" RepeatColumns="2" Width="500" > <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>RosyBrown</asp:ListItem> <asp:ListItem>DodgerBlue</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> <asp:ListItem>HotPink</asp:ListItem> <asp:ListItem>Violet</asp:ListItem> </asp:CheckBoxList> </ContentTemplate> </cc1:TabPanel> <cc1:TabPanel ID="TabPanel3" runat="server"> <HeaderTemplate> Sky Image </HeaderTemplate> <ContentTemplate> <asp:Image ID="Image2" runat="server" /> </ContentTemplate> </cc1:TabPanel> </cc1:TabContainer> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-tabcontainer-and-tabpanel-how-to.html
Example 195
Ajax AlwaysVisibleControlExtender - How to use AlwaysVisibleControlExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string[] colorList = Enum.GetNames(typeof(KnownColor)); foreach (string color in colorList) { Label1.Text += color + "<br />"; } } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax AlwaysVisibleControlExtender - How to use AlwaysVisibleControlExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using AlwaysVisibleControlExtender</h2> <hr width="600" align="left" color="CornFlowerBlue" /> <asp:Label ID="Label1" runat="server" ForeColor="DodgerBlue" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large" > </asp:Label> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:AlwaysVisibleControlExtender ID="AlwaysVisibleControlExtender1" runat="server" TargetControlID="Panel1" VerticalSide="Top" HorizontalSide="Right" > </cc1:AlwaysVisibleControlExtender>
<asp:Panel ID="Panel1" runat="server" Width="250" Height="100" BorderWidth="2" BorderColor="LightPink" BackColor="OrangeRed" HorizontalAlign="Center" > <br /> <asp:TextBox ID="TextBox1" runat="server" BackColor="LightGoldenrodYellow" ForeColor="HotPink" Font-Bold="false" Text="Your Email" Width="200" Height="25" > </asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Subscribe RSS Feed" Font-Bold="true" ForeColor="SaddleBrown" Height="40" /> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-alwaysvisiblecontrolextender-how.html
Example 196
Ajax CalendarExtender - How to use CalendarExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { TextBox1.ForeColor = Color.LightGoldenrodYellow; TextBox1.ForeColor = Color.DeepPink; TextBox1.Font.Bold = true; TextBox1.Font.Size = FontUnit.Medium; TextBox1.Font.Name = "Comic Sans MS"; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax CalendarExtender - How to use CalendarExtender in asp.net ajax</title> <style type="text/css"> .CalendarCSS { background-color:OrangeRed; color:Snow; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using CalendarExtender</h2> <hr width="500" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" CssClass="CalendarCSS" > </cc1:CalendarExtender> <asp:Label ID="Label1" runat="server"
ForeColor="DodgerBlue" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large" Text="Arrival Date: " Font-Underline="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-calendarextender-how-to-use.html
Example 197
Ajax CollapsiblePanelExtender - How to use CollapsiblePanelExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax CollapsiblePanelExtender - How to use CollapsiblePanelExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: Using CollapsiblePanelExtender</h2> <hr width="600" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:CollapsiblePanelExtender ID="CollapsiblePanelExtender1" runat="server" TargetControlID="Panel2" ExpandControlID="Panel1" CollapseControlID="Panel1" TextLabelID="Label1" ExpandedText="-" CollapsedText="+" > </cc1:CollapsiblePanelExtender> <asp:Label ID="Label1" runat="server" ForeColor="Crimson" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="XX-Large" > </asp:Label> <asp:Panel ID="Panel1" runat="server" Width="500" > <asp:Image ID="Image1" runat="server"
ImageUrl="~/Images/SeaBeach.jpg" Height="150" BorderWidth="1" BorderColor="DarkSeaGreen" /> </asp:Panel> <asp:Panel ID="Panel2" runat="server" Width="500" > <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/SeaBeach.jpg" BorderColor="DarkBlue" BorderWidth="2" /> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-collapsiblepanelextender-how-to.html
Example 198
Ajax ConfirmButtonExtender - How to use ConfirmButtonExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { RadioButtonList1.Items.Remove(RadioButtonList1.SelectedItem); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ConfirmButtonExtender - How to use ConfirmButtonExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: Using ConfirmButtonExtender</h2> <hr width="600" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server" TargetControlID="Button1" ConfirmText="Are you sure you wanted to delete this color?" > </cc1:ConfirmButtonExtender> <asp:RadioButtonList ID="RadioButtonList1" runat="server" ForeColor="Snow" BackColor="Crimson" BorderColor="Orange" BorderWidth="1" RepeatColumns="2" Width="500" > <asp:ListItem Selected="True">Crimson</asp:ListItem> <asp:ListItem>LawnGreen</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> <asp:ListItem>HotPink</asp:ListItem> <asp:ListItem>LightPink</asp:ListItem> <asp:ListItem>Salmon</asp:ListItem> <asp:ListItem>DarkSeaGreen</asp:ListItem> </asp:RadioButtonList>
<br /> <asp:Button ID="Button1" runat="server" Text="Delete Selected Color" Font-Bold="true" ForeColor="DodgerBlue" Height="40" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-confirmbuttonextender-how-to-use.html
Example 199
Ajax DragPanelExtender - How to use DragPanelExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax DragPanelExtender - How to use DragPanelExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax Control Toolkit Example: Using DragPanelExtender</h2> <hr width="600" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:DragPanelExtender ID="DragPanelExtender1" runat="server" TargetControlID="Panel1" DragHandleID="Label1" > </cc1:DragPanelExtender> <asp:Panel ID="Panel1" runat="server" BackColor="Snow" Width="250" HorizontalAlign="Center" > <asp:Label ID="Label1" runat="server" Width="100%" BackColor="HotPink" Font-Bold="true" ForeColor="Snow" Text="Drag Me" > </asp:Label> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/RedFlower.jpg"
Height="275" BorderWidth="3" BorderColor="DeepPink" /> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-dragpanelextender-how-to-use.html
Example 200
Ajax ListSearchExtender - How to use ListSearchExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { string[] colorList = Enum.GetNames(typeof(KnownColor)); ListBox1.DataSource = colorList; ListBox1.DataBind(); } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ListSearchExtender - How to use ListSearchExtender in asp.net ajax</title> <style type="text/css"> .PromptCSS { color:DodgerBlue; font-size:large; font-style:italic; font-weight:bold; background-color:AliceBlue; height:25px; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using ListSearchExtender</h2> <hr width="550" align="left" color="LawnGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:ListSearchExtender ID="ListSearchExtender1" runat="server" TargetControlID="ListBox1" PromptCssClass="PromptCSS" > </cc1:ListSearchExtender> <br /><br /> <asp:ListBox
ID="ListBox1" runat="server" BackColor="Pink" ForeColor="DeepPink" Font-Size="Medium" Font-Bold="true" Height="250" > </asp:ListBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-listsearchextender-how-to-use.html
Example 201
Ajax NumericUpDownExtender - How to use NumericUpDownExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { int number =Convert.ToInt32(TextBox1.Text); Image1.Width = 50 * number; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax NumericUpDownExtender - How to use NumericUpDownExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax Control Toolkit Example: Using NumericUpDownExtender</h2> <hr width="600" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="TextBox1" Minimum="1" Maximum="25" Width="100" > </cc1:NumericUpDownExtender> <asp:Label ID="Label1" runat="server" Text="Multiply original Image Size" Font-Bold="true" ForeColor="Crimson" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="Crimson" BackColor="LightGoldenrodYellow" >
</asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Resize Image" Font-Bold="true" OnClick="Button1_Click" ForeColor="Crimson" Height="30" /> <br /><br /> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/RedTree.jpg" Width="50" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-numericupdownextender-how-to-use.html
Example 202
Ajax RoundedCornersExtender - How to use RoundedCornersExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax RoundedCornersExtender - How to use RoundedCornersExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkSeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using RoundedCornersExtender</h2> <hr width="600" align="left" color="DarkSeaGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:RoundedCornersExtender ID="RoundedCornersExtender1" runat="server" TargetControlID="CheckBoxList1" Radius="20" > </cc1:RoundedCornersExtender> <br /><br /> <asp:CheckBoxList ID="CheckBoxList1" runat="server" BackColor="OrangeRed" ForeColor="Snow" RepeatColumns="3" Width="450" Font-Names="Comic Sans MS" Font-Size="Large" > <asp:ListItem>OrangeRed</asp:ListItem> <asp:ListItem>BurlyWood</asp:ListItem> <asp:ListItem>SaddleBrown</asp:ListItem> <asp:ListItem>RosyBrown</asp:ListItem> <asp:ListItem>Maroon</asp:ListItem> <asp:ListItem>SeaGreen</asp:ListItem> <asp:ListItem>DarkBlue</asp:ListItem> </asp:CheckBoxList> </div> </form>
</body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-roundedcornersextender-how-to-use.html
Example 203
Ajax DropShadowExtender - How to use DropShadowExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax DropShadowExtender - How to use DropShadowExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Crimson; font-style:italic;">Ajax Control Toolkit Example: Using DropShadowExtender</h2> <hr width="600" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="Panel1" > </cc1:DropShadowExtender> <br /><br /> <asp:Panel ID="Panel1" runat="server" BackColor="Gray" ForeColor="Snow" Width="300" Height="150" HorizontalAlign="Center" > <br /> <asp:TextBox ID="TextBox1" runat="server" BackColor="Snow" ForeColor="OrangeRed" Text="email" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1"
runat="server" Font-Bold="true" ForeColor="SlateBlue" Height="40" Text="Subscribe Our Newsletter" /> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-dropshadowextender-how-to-use.html
Example 204
Ajax Accordion and AccordionPane - How to use Accordion in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Accordion and AccordionPane - How to use Accordion in asp.net ajax</title> <style type="text/css"> .HeaderCSS { color:Snow; background-color:Crimson; font-size:medium; border:solid 1px salmon; font-weight:bold; } .HeaderSelectedCSS { color:Snow; background-color:OrangeRed; font-weight:bold; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkSeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using Accordion</h2> <hr width="450" align="left" color="DarkSeaGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:Accordion runat="server" ID="Accordion1" HeaderCssClass="HeaderCSS" HeaderSelectedCssClass="HeaderSelectedCSS" Width="500" BorderColor="Orange" BorderWidth="2" > <Panes> <cc1:AccordionPane runat="server" ID="AccordionPane1">
<Header>Red Orchid</Header> <Content> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/RedOrchid.jpg" Width="200" /> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane2"> <Header>Green Orchid</Header> <Content> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/GreenOrchid.jpg" /> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane3"> <Header>Blue Orchid</Header> <Content> <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/BlueOrchid.jpg" /> </Content> </cc1:AccordionPane> </Panes> </cc1:Accordion> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-accordion-and-accordionpane-how-to.html
Example 205
Ajax PasswordStrength - How to use PasswordStrength in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax PasswordStrength - How to use PasswordStrength in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkSeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using PasswordStrength</h2> <hr width="550" align="left" color="DarkSeaGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:PasswordStrength ID="PasswordStrength1" runat="server" TargetControlID="TextBox1" > </cc1:PasswordStrength> <br /><br /> <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Bold="true" Text="Input your password" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-passwordstrength-how-to-use.html
Example 206
Ajax TextBoxWatermarkExtender - How to use TextBoxWatermarkExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Subscription Successful!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax TextBoxWatermarkExtender - How to use TextBoxWatermarkExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using TextBoxWatermarkExtender</h2> <hr width="550" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:TextBoxWatermarkExtender ID="TexBoxWatermarkExtender1" runat="server" TargetControlID="TextBox1" WatermarkText="Input your email" > </cc1:TextBoxWatermarkExtender> <br /> <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Bold="true" Font-Size="Large" > </asp:Label> <br /><br /> <asp:TextBox ID="TextBox1" runat="server" ForeColor="SeaGreen" > </asp:TextBox> <asp:Button ID="Button1"
runat="server" Text="Subscribe RSS Feed" OnClick="Button1_Click" Height="30" Font-Bold="true" ForeColor="Green" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-textboxwatermarkextender-how-to.html
Example 207
Ajax SliderExtender - How to use SliderExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void LinkButton1_Click(object sender, EventArgs e) { int imageWidth = Convert.ToInt32(TextBox2.Text); Image1.Width = 1 * imageWidth; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax SliderExtender - How to use SliderExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkSeaGreen; font-style:italic;">Ajax Control Toolkit Example: Using SliderExtender</h2> <hr width="450" align="left" color="DarkSeaGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:SliderExtender ID="SliderExtender1" runat="server" TargetControlID="TextBox1" BoundControlID="TextBox2" Minimum="200" Maximum="600" > </cc1:SliderExtender> <br /> <table> <tr> <td> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> </td> <td> <asp:TextBox ID="TextBox2" runat="server"
ForeColor="Crimson" Width="25" > </asp:TextBox> </td> <td> <asp:LinkButton ID="LinkButton1" runat="server" Text="Change Image Size" ForeColor="DodgerBlue" Font-Bold="true" BorderColor="CornflowerBlue" BorderWidth="1" OnClick="LinkButton1_Click" > </asp:LinkButton> </td> </tr> </table> <br /> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Tiger.jpg" Width="200" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-sliderextender-how-to-use.html
Example 208
Ajax SliderExtender Steps and Length - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void LinkButton1_Click(object sender, EventArgs e) { int imageWidth = Convert.ToInt32(TextBox2.Text); Image1.Width = 1 * imageWidth; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax SliderExtender Steps and Length - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: How To Use Steps In Slider</h2> <hr width="575" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:SliderExtender ID="SliderExtender1" runat="server" TargetControlID="TextBox1" BoundControlID="TextBox2" Minimum="100" Maximum="700" Orientation="Vertical" Steps="7" Length="250" > </cc1:SliderExtender> <table border="0" cellpadding="0" cellspacing="10"> <tr valign="top"> <td> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <asp:TextBox ID="TextBox2" runat="server" ForeColor="Crimson"
Width="25" > </asp:TextBox> <br /> <asp:LinkButton ID="LinkButton1" runat="server" Text="Apply" ForeColor="LightPink" Font-Bold="true" BorderColor="DeepPink" BorderWidth="1" OnClick="LinkButton1_Click" BackColor="Crimson" > </asp:LinkButton> </td> <td> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/SeaBird.jpg" Width="100" /> </td> </tr> </table> <br /><br /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-sliderextender-steps-and-length.html
Example 209
Ajax ValidatorCalloutExtender - How to use ValidatorCalloutExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted name: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax ValidatorCalloutExtender - How to use ValidatorCalloutExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Green; font-style:italic;">Ajax Control Toolkit Example: Using ValidatorCalloutExtender</h2> <hr width="575" align="left" color="LawnGreen" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:ValidatorCalloutExtender ID="ValidatorCalloutExtender1" runat="server" TargetControlID="RequiredFieldValidator1" > </cc1:ValidatorCalloutExtender> <asp:Label ID="Label1" runat="server" ForeColor="Salmon" Font-Size="Large" Font-Names="Comic Sans MS" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Name" Font-Bold="true" ForeColor="DeepPink" > </asp:Label> <asp:TextBox ID="TextBox1"
runat="server" > </asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="Input your name!" Display="None" > </asp:RequiredFieldValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Name" Height="40" Font-Bold="true" ForeColor="DeepPink" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-validatorcalloutextender-how-to.html
Example 210
Ajax NumericUpDownExtender RefValues - Using text in NumericUpDownExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.ForeColor = System.Drawing.Color.FromName(TextBox1.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax NumericUpDownExtender RefValues - Using text in NumericUpDownExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SeaGreen; font-style:italic;">Ajax NumericUpDownExtender Example: Using RefValues</h2> <hr width="600" align="left" color="LawnGreen" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="TextBox1" Width="200" RefValues = "Crimson;DeepPink;DodgerBlue;HotPink;DarkSalmon;IndianRed;DarkSeaGreen;SeaGreen" > </cc1:NumericUpDownExtender> <asp:Label ID="Label1" runat="server" Text="Change this text color." Font-Bold="true" Font-Size="X-Large" Font-Names="Comic Sans MS" > </asp:Label> <br /><br /><br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="IndianRed"
BackColor="LightGoldenrodYellow" > </asp:TextBox> <asp:Button ID="Button1" runat="server" Text="Change Label" Font-Bold="true" OnClick="Button1_Click" ForeColor="IndianRed" Height="30" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-numericupdownextender-refvalues.html
Example 211
Ajax Accordion HeaderCssClass - How to use HeaderCssClass in Accordion <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Accordion HeaderCssClass - How to use HeaderCssClass in Accordion</title> <style type="text/css"> .HeaderCSS { color:AliceBlue; background-color:DodgerBlue; font-size:large; border:solid 1px CornFlowerBlue; font-style:italic; font-family:Comic Sans MS; height:30px; } .HeaderSelectedCSS { color:Snow; background-color:SlateBlue; font-weight:bold; height:25px; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Crimson; font-style:italic;">Ajax Accordion Example: Using HeaderCssClass</h2> <hr width="450" align="left" color="Salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:Accordion runat="server" ID="Accordion1" HeaderCssClass="HeaderCSS" HeaderSelectedCssClass="HeaderSelectedCSS" Width="500" BorderColor="CornflowerBlue" BorderWidth="2" >
<Panes> <cc1:AccordionPane runat="server" ID="AccordionPane1"> <Header>Red Flower</Header> <Content> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/RedFlower.gif" Height="400"/> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane2"> <Header>Yellow Flower</Header> <Content> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/YellowFlower.jpg" Height="400" /> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane3"> <Header>Upload Flower Image</Header> <Content> <asp:Panel ID="Panel1" runat="server" Height="200" > <br /><br /> <asp:FileUpload ID="FileUpload1" runat="server" ForeColor="Snow" BackColor="OrangeRed" Font-Size="Large" BorderWidth="1" BorderColor="SaddleBrown" Font-Italic="true" Font-Names="Comic Sans MS" /> <asp:Button ID="Button1" runat="server" Font-Bold="true" ForeColor="OrangeRed" Text="Upload Now" Height="40" /> </asp:Panel> </Content> </cc1:AccordionPane> </Panes> </cc1:Accordion> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-accordion-headercssclass-how-to.html
Example 212
Ajax Accordion HeaderSelectedCssClass - How to use HeaderSelectedCssClass in Accordion <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax Accordion HeaderSelectedCssClass - How to use HeaderSelectedCssClass in Accordion</title> <style type="text/css"> .HeaderCSS { color:Snow; background-color:DarkSeaGreen; font-size:large; border:solid 1px MediumSeaGreen; } .HeaderSelectedCSS { color:Snow; background-color:OrangeRed; font-weight:bold; height:45px; font-family:Comic Sans MS; font-size:larger; text-align:center; padding-top:5px; border:solid 2px Crimson; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax Accordion Example: Using HeaderSelectedCssClass</h2> <hr width="550" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:Accordion runat="server" ID="Accordion1" HeaderCssClass="HeaderCSS" HeaderSelectedCssClass="HeaderSelectedCSS" Width="600" BorderColor="Orange"
BorderWidth="2" > <Panes> <cc1:AccordionPane runat="server" ID="AccordionPane1"> <Header>Fungus</Header> <Content> <asp:Image ID="Image1" runat="server" ImageUrl="~/Images/Fungus.jpg"/> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane2"> <Header>Bacteria</Header> <Content> <asp:Image ID="Image2" runat="server" ImageUrl="~/Images/Bacteria.jpg"/> </Content> </cc1:AccordionPane> <cc1:AccordionPane runat="server" ID="AccordionPane3"> <Header>Virus</Header> <Content> <asp:Image ID="Image3" runat="server" ImageUrl="~/Images/Virus.jpg"/> </Content> </cc1:AccordionPane> </Panes> </cc1:Accordion> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-accordion-headerselectedcssclass.html
Example 213
Ajax HoverMenuExtender - How to use HoverMenuExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { Label1.ForeColor = System.Drawing.Color.FromName(RadioButtonList1.SelectedItem.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax HoverMenuExtender - How to use HoverMenuExtender in asp.net ajax</title> <style type="text/css"> .PanelCSS { visibility:hidden; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax Control Toolkit Example: Using HoverMenuExtender</h2> <hr width="550" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:HoverMenuExtender ID="HoverMenuExtender1" runat="server" TargetControlID="Label1" PopupControlID="Panel1" PopupPosition="Bottom" > </cc1:HoverMenuExtender> <br /><br /> <asp:Label ID="Label1" runat="server" Text="Color changeable label." Font-Size="XX-Large" Font-Names="Comic Sans MS" > </asp:Label>
<asp:Panel ID="Panel1" runat="server" Width="300" BorderColor="Gray" BorderWidth="1" CssClass="PanelCSS" > <asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatColumns="3" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true" > <asp:ListItem>Tan</asp:ListItem> <asp:ListItem>Crimson</asp:ListItem> <asp:ListItem>DarkBlue</asp:ListItem> <asp:ListItem>SeaGreen</asp:ListItem> <asp:ListItem>OrangeRed</asp:ListItem> <asp:ListItem>Magenta</asp:ListItem> <asp:ListItem>DeepPink</asp:ListItem> </asp:RadioButtonList> </asp:Panel> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-hovermenuextender-how-to-use.html
Example 214
Ajax PagingBulletedListExtender IndexSize - How to use IndexSize <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { BulletedList1.ForeColor = Color.Red; BulletedList1.Font.Name = "Verdana"; BulletedList1.Font.Size = FontUnit.Medium; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax PagingBulletedListExtender IndexSize - How to use IndexSize</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OrangeRed; font-style:italic;">Ajax PagingBulletedListExtender Example: Using IndexSize</h2> <hr width="575" align="left" color="Orange" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select Top 25 ProductID, ProductName From Products" > </asp:SqlDataSource> <cc1:PagingBulletedListExtender ID="PagingBulletedListExtender1" runat="server" TargetControlID="BulletedList1" IndexSize="2" > </cc1:PagingBulletedListExtender> <asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="SqlDataSource1"
DataValueField="ProductID" DataTextField="ProductName" > </asp:BulletedList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-pagingbulletedlistextender.html
Example 215
Ajax PagingBulletedListExtender - Using SelectIndexCssClass and UnselectIndexCssClass <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { BulletedList1.ForeColor = Color.Crimson; BulletedList1.Font.Italic = true; BulletedList1.Font.Size = FontUnit.Medium; BulletedList1.Font.Name = "Comic Sans MS"; BulletedList1.BulletStyle = BulletStyle.LowerRoman; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax PagingBulletedListExtender - Using SelectIndexCssClass and UnselectIndexCssClass</title> <style type="text/css"> .SelectIndexCSS { font-weight:bold; font-size:large; } .UnSelectIndexCSS { Color:Green; font-style:italic; } </style> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Tomato; font-style:italic;">Ajax PagingBulletedListExtender Example: Using SelectIndexCssClass</h2> <hr width="650" align="left" color="Salmon" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="Select Top 30 ProductID, ProductName From Products" > </asp:SqlDataSource> <cc1:PagingBulletedListExtender ID="PagingBulletedListExtender1" runat="server" TargetControlID="BulletedList1" MaxItemPerPage="6" SelectIndexCssClass="SelectIndexCSS" UnselectIndexCssClass="UnSelectIndexCSS" > </cc1:PagingBulletedListExtender> <asp:BulletedList ID="BulletedList1" runat="server" DataSourceID="SqlDataSource1" DataValueField="ProductID" DataTextField="ProductName" > </asp:BulletedList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-pagingbulletedlistextender-using.html
Example 216
Ajax PagingBulletedListExtender MaxItemPerPage - How to use MaxItemPerPage <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { BulletedList1.ForeColor = Color.SeaGreen; BulletedList1.Font.Italic = true; BulletedList1.Font.Name = "Comic Sans MS"; BulletedList1.Font.Size = FontUnit.Medium; BulletedList1.BulletStyle = BulletStyle.Square; } } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax PagingBulletedListExtender MaxItemPerPage - How to use MaxItemPerPage</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SlateBlue; font-style:italic;">Ajax PagingBulletedListExtender Example: Using MaxItemPerPage</h2> <hr width="650" align="left" color="CornFlowerBlue" /> <br /><br /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>" SelectCommand="Select Top 15 ProductID, ProductName From Products" > </asp:SqlDataSource> <cc1:PagingBulletedListExtender ID="PagingBulletedListExtender1" runat="server" TargetControlID="BulletedList1" MaxItemPerPage="5" > </cc1:PagingBulletedListExtender> <asp:BulletedList ID="BulletedList1"
runat="server" DataSourceID="SqlDataSource1" DataValueField="ProductID" DataTextField="ProductName" > </asp:BulletedList> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-pagingbulletedlistextender_18.html
Example 217
Ajax MaskedEditExtender DisplayMoney - How to use in MaskedEditExtender <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted salary: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender DisplayMoney - How to use in MaskedEditExtender</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DodgerBlue; font-style:italic;">Ajax MaskedEditValidator Example: Using DisplayMoney</h2> <hr width="550" align="left" color="SkyBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" Font-Size="X-Large" ForeColor="Green" Font-Bold="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Your Salary [9999 Format]" ForeColor="Orange" Font-Bold="true" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="HotPink" Font-Size="Large"
Font-Names="Comic Sans MS" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" DisplayMoney="Left" Mask="9999" MaskType="Number" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" InvalidValueMessage="inputted salary is not valid" EmptyValueMessage="Input salary" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit Your Salary" Height="40" Font-Bold="true" ForeColor="DodgerBlue" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-displaymoney.html
Example 218
Ajax MaskedEditExtender Mask - How to use Mask in MaskedEditExtender <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { TextBox1.ForeColor = Color.DeepPink; TextBox1.BackColor = Color.Snow; TextBox1.Font.Name = "Verdana"; TextBox1.Font.Size = FontUnit.Large; TextBox1.Height = 35; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted date: "; Label1.Text += Convert.ToDateTime(TextBox1.Text).ToLongDateString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender Mask - How to use Mask in MaskedEditExtender</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:RosyBrown; font-style:italic;">Ajax MaskedEditValidator Example: Using Mask</h2> <hr width="475" align="left" color="BurlyWood" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" Font-Size="X-Large" ForeColor="Olive" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server"
Text="Input a date [99/99/9999][mm/dd/yyyy] " ForeColor="SkyBlue" Font-Bold="true" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input date" InvalidValueMessage="inputted date not valid" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Your Date" Font-Bold="true" ForeColor="DeepPink" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-mask-how-to-use.html
Example 219
Ajax MaskedEditExtender - How to use MaskedEditExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted date: " + Convert.ToDateTime(TextBox1.Text).ToLongDateString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender - How to use MaskedEditExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using MaskedEditExtender</h2> <hr width="600" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Size="Large" Font-Italic="true" Font-Bold="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Arrival Date [mm/dd/yyyy] " ForeColor="Green" Font-Bold="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <cc1:MaskedEditExtender
ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input date" InvalidValueMessage="date not valid" > </cc1:MaskedEditValidator> <br /> <asp:Button ID="Button1" runat="server" Text="Submit Arrival Date" Font-Bold="true" ForeColor="Green" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-how-to-use.html
Example 220
Ajax MaskedEditValidator - How to use MaskedEditValidator in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted date: "; Label1.Text += Convert.ToDateTime(TextBox1.Text).ToLongDateString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditValidator - How to use MaskedEditValidator in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:IndianRed; font-style:italic;">Ajax Control Toolkit Example: Using MaskedEditValidator</h2> <hr width="600" align="left" color="Salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" ForeColor="DeepPink" Font-Size="Large" Font-Italic="true" Font-Bold="true" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Meeting Date [mm/dd/yyyy] " ForeColor="DarkSeaGreen" Font-Bold="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DarkSeaGreen" Font-Bold="true"
ForeColor="Snow" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input date" InvalidValueMessage="inputted date not valid" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Next Meeting Date" Font-Bold="true" ForeColor="SaddleBrown" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitvalidator-how-to-use.html
Example 221
Ajax MaskedEditExtender MaskType Date - How to use in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { Label1.ForeColor = Color.DeepPink; Label1.Font.Name = "Comic Sans MS"; Label1.Font.Size = FontUnit.Large; Label1.Font.Bold = true; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted date: "; Label1.Text += Convert.ToDateTime(TextBox1.Text).ToLongDateString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender MaskType Date - How to use in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SlateBlue; font-style:italic;">Ajax MaskedEditValidator Example: Using MaskType Date</h2> <hr width="600" align="left" color="LightSlateBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Input a date [mm/dd/yyyy] " ForeColor="DodgerBlue" Font-Bold="true"
> </asp:Label> <asp:TextBox ID="TextBox1" runat="server" BackColor="DodgerBlue" Font-Bold="true" ForeColor="Snow" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input date" InvalidValueMessage="inputted date not valid" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Your Sample Date" Font-Bold="true" ForeColor="SlateBlue" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-masktype-date.html
Example 222
Ajax MaskedEditExtender MaskType DateTime - How to use mask date time both <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { TextBox1.ForeColor = Color.OrangeRed; TextBox1.BackColor = Color.Snow; TextBox1.Font.Name = "Verdana"; TextBox1.Font.Size = FontUnit.Large; TextBox1.Height = 32; Label1.ForeColor = Color.MediumSeaGreen; Label1.Font.Size = FontUnit.XLarge; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your submitted date time: "; Label1.Text += Convert.ToDateTime(TextBox1.Text); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender MaskType DateTime - How to use mask date time both</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SlateBlue; font-style:italic;">Ajax MaskedEditValidator Example: MaskType DateTime</h2> <hr width="550" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server"
Text="Meeting Date Time [mm/dd/yyyy hh:mm:ss]" ForeColor="Orange" Font-Bold="true" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99/99/9999 99:99:99" MaskType="DateTime" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input Date and Time" InvalidValueMessage="inputted date time not valid" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Meeting Date and Time" Font-Bold="true" ForeColor="DeepPink" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-masktype.html
Example 223
Ajax MaskedEditExtender MaskType Number - How to use mask Number <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { Button1.Font.Bold = true; Button1.ForeColor = Color.OliveDrab; Button1.Height = 40; Label1.ForeColor = Color.MediumSeaGreen; Label1.Font.Size = FontUnit.XLarge; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "You submitted age: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender MaskType Number - How to use mask Number</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SlateBlue; font-style:italic;">Ajax MaskedEditValidator Example: MaskType Number</h2> <hr width="550" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Your Age [999 Format]" ForeColor="Orange" Font-Bold="true"
> </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="HotPink" Font-Size="Large" Font-Names="Comic Sans MS" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="999" MaskType="Number" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input age" InvalidValueMessage="inputted age not valid" MaximumValue="120" MinimumValue="18" MaximumValueMessage="Age must be <120" MinimumValueMessage="Age must be >18" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Your Age" OnClick="Button1_Click" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-masktype-number.html
Example 224
Ajax MaskedEditExtender MaskType Time - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { TextBox1.ForeColor = Color.OliveDrab; TextBox1.BackColor = Color.Snow; TextBox1.Font.Name = "Verdana"; TextBox1.Font.Size = FontUnit.Large; TextBox1.Height = 35; Label1.ForeColor = Color.OrangeRed; Label1.Font.Size = FontUnit.XLarge; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Meeting Time "; Label1.Text += Convert.ToDateTime(TextBox1.Text).ToShortTimeString(); } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax MaskedEditExtender MaskType Time - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DeepPink; font-style:italic;">Ajax MaskedEditValidator Example: MaskType Time</h2> <hr width="475" align="left" color="Pink" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <br /><br /> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /><br /> <asp:Label ID="Label2" runat="server" Text="Meeting Time [99:99:99][hh/mm/ss] "
ForeColor="Olive" Font-Bold="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <cc1:MaskedEditExtender ID="MaskedEditExtender1" runat="server" TargetControlID="TextBox1" Mask="99:99:99" MaskType="Time" MessageValidatorTip="true" > </cc1:MaskedEditExtender> <cc1:MaskedEditValidator ID="MaskedEditValidator1" runat="server" ControlToValidate="TextBox1" ControlExtender="MaskedEditExtender1" IsValidEmpty="false" EmptyValueMessage="Input time" InvalidValueMessage="inputted time not valid" > </cc1:MaskedEditValidator> <br /><br /> <asp:Button ID="Button1" runat="server" Text="Submit Meeting Time" Font-Bold="true" ForeColor="RosyBrown" OnClick="Button1_Click" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-maskededitextender-masktype-time.html
Example 225
Ajax FilteredTextBoxExtender - How to use FilteredTextBoxExtender in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your ZIP Code: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender - How to use FilteredTextBoxExtender in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:DarkBlue; font-style:italic;">Ajax Control Toolkit Example: Using FilteredTextBoxExtender</h2> <hr width="600" align="left" color="CornFlowerBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterType="Numbers" FilterMode="ValidChars" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" ForeColor="OrangeRed" Font-Size="X-Large" Height="75" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" ForeColor="DodgerBlue" Font-Italic="true" Font-Names="Comic Sans MS" Font-Size="Large"
Text="Zip Code " Font-Underline="true" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" BackColor="Snow" ForeColor="DeepPink" Font-Names="Comic Sans MS" Font-Size="Medium" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" Font-Bold="true" Height="40" OnClick="Button1_Click" Text="Submit ZIP Code" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-how-to-use.html
Example 226
Ajax FilteredTextBoxExtender FilterMode InvalidChars - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { Label1.ForeColor = Color.DeepPink; Label1.BackColor = Color.Snow; Label1.Font.Name = "Comic Sans MS"; Label1.Height = 75; Label1.Width = 450; Label1.Font.Size = FontUnit.XLarge; Label1.Font.Italic = true; Label2.ForeColor = Color.Salmon; Label2.Font.Bold = true; Label2.Font.Underline = true; Label2.Font.Italic = true; Label2.Font.Size = FontUnit.Large; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Hi " + TextBox1.Text +"!"; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterMode InvalidChars - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OliveDrab; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterMode InvalidChars</h2> <hr width="650" align="left" color="salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterMode="InvalidChars" InvalidChars="*~!./;;,\[]{}"
> </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Text="Your Name" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" Height="35" Font-Size="Medium" ForeColor="OrangeRed" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="Olive" OnClick="Button1_Click" Text="Submit Your Name" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtermode.html
Example 227
Ajax FilteredTextBoxExtender FilterMode ValidChars - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { TextBox1.Font.Name = "Comic Sans MS"; TextBox1.Font.Bold = true; TextBox1.Font.Size = FontUnit.Medium; TextBox1.ForeColor = System.Drawing.Color.DeepPink; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your City Code: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterMode ValidChars - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SkyBlue; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterMode ValidChars</h2> <hr width="650" align="left" color="LightBlue" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterType="Numbers" FilterMode="ValidChars" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" ForeColor="DeepPink" Height="70" Font-Size="X-Large"
Font-Bold="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Italic="true" ForeColor="SeaGreen" Font-Names="Comic Sans MS" Font-Size="Large" Text="City Code (Only Numbers)" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="SeaGreen" OnClick="Button1_Click" Text="Submit City Code" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtermode_22.html
Example 228
Ajax FilteredTextBoxExtender FilterType LowercaseLetters - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { TextBox1.Font.Name = "Comic Sans MS"; TextBox1.Font.Bold = true; TextBox1.Height = 40; TextBox1.Width = 250; TextBox1.Font.Size = FontUnit.Large; TextBox1.ForeColor = System.Drawing.Color.DeepPink; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "your city name " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterType LowercaseLetters - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SkyBlue; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterType LowercaseLetters</h2> <hr width="650" align="left" color="Salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterType="LowercaseLetters" FilterMode="ValidChars" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" ForeColor="IndianRed"
Height="70" Font-Size="X-Large" Font-Bold="true" Font-Italic="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Italic="false" ForeColor="DeepSkyBlue" Font-Names="Comic Sans MS" Font-Size="Large" Text="Your City Name(Only LowercaseLetters)" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DeepSkyBlue" OnClick="Button1_Click" Text="Submit Your City Name" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtertype.html
Example 229
Ajax FilteredTextBoxExtender FilterType Numbers - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Area Code: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterType Numbers - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:Crimson; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterType Numbers</h2> <hr width="625" align="left" color="RosyBrown" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterType="Numbers" FilterMode="ValidChars" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" ForeColor="SkyBlue" Height="70" Font-Size="X-Large" Font-Bold="true" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Italic="true" ForeColor="SeaGreen" Font-Names="Comic Sans MS" Font-Size="Large"
Text="Area Code(Only Numbers)" > </asp:Label> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" Font-Names="Comic Sans MS" BackColor="Snow" ForeColor="SeaGreen" Font-Size="Medium" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DodgerBlue" OnClick="Button1_Click" Text="Submit Area Code" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtertype_23.html
Example 230
Ajax FilteredTextBoxExtender FilterType UppercaseLetters - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Import Namespace="System.Drawing" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { if(!Page.IsPostBack) { Label1.ForeColor = Color.DeepPink; Label1.BackColor = Color.Snow; Label1.Height = 70; Label1.Width = 450; Label1.Font.Name = "Comic Sans MS"; Label1.Font.Size = FontUnit.XLarge; Label1.Font.Italic = true; } } protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Your Country: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterType UppercaseLetters - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:SkyBlue; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterType UppercaseLetters</h2> <hr width="650" align="left" color="MistyRose" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterMode="ValidChars" FilterType="UppercaseLetters" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1"
runat="server" > </asp:Label> <br /> <asp:Label ID="Label2" runat="server" Font-Italic="false" ForeColor="MediumSlateBlue" Font-Names="Comic Sans MS" Font-Size="Large" Text="Your Country Name(Only UppercaseLetters)" > </asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" Height="35" Font-Size="Medium" ForeColor="OrangeRed" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="Teal" OnClick="Button1_Click" Text="Submit Country Name" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtertype_2654.html
Example 231
Ajax FilteredTextBoxExtender FilterType Custom - How to use <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void Button1_Click(object sender, EventArgs e) { Label1.Text = "Hi you make: " + TextBox1.Text; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax FilteredTextBoxExtender FilterType Custom - How to use</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OrangeRed; font-style:italic;">Ajax FilteredTextBoxExtender Example: Using FilterType Custom</h2> <hr width="650" align="left" color="salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server" TargetControlID="TextBox1" FilterMode="ValidChars" FilterType="Custom" ValidChars="R,r,O,o,S,s,E,e" > </cc1:FilteredTextBoxExtender> <br /> <asp:Label ID="Label1" runat="server" Font-Size="XX-Large" ForeColor="CornflowerBlue" > </asp:Label> <br /><br /><br /> <asp:Label ID="Label2" runat="server" Text="Make a word from [R,r,O,o,S,s,E,e]" Font-Bold="true" Font-Size="Large" ForeColor="DeepPink" >
</asp:Label> <br /> <asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" Height="35" Font-Size="Medium" ForeColor="DodgerBlue" Width="250" > </asp:TextBox> <br /><br /> <asp:Button ID="Button1" runat="server" ForeColor="DeepPink" OnClick="Button1_Click" Text="Submit Your Word" Font-Bold="true" Height="40" /> </div> </form> </body> </html> http://asp-net-example.blogspot.com/2009/11/ajax-filteredtextboxextender-filtertype_2820.html
Example 232
Ajax AsyncFileUpload - How to use AsyncFileUpload in asp.net ajax <%@ Page Language="C#" AutoEventWireup="true" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> protected void UploadComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e) { string filePath = Request.PhysicalApplicationPath+ "Image\\" + AsyncFileUpload1.PostedFile.FileName; AsyncFileUpload1.SaveAs(filePath); } </script> <script type="text/javascript"> function showConfirmation() { document.getElementById('Label1').innerText = 'upload complete.'; } </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head id="Head1" runat="server"> <title>Ajax AsyncFileUpload - How to use AsyncFileUpload in asp.net ajax</title> </head> <body> <form id="form1" runat="server"> <div> <h2 style="color:OrangeRed; font-style:italic;">Ajax AsyncFileUpload Example: How To Use AsyncFileUpload</h2> <hr width="650" align="left" color="salmon" /> <asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager> <cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server" OnUploadedComplete="UploadComplete" OnClientUploadComplete="showConfirmation" BackColor="Pink" /> <br /> <asp:Label ID="Label1" runat="server" Font-Size="Large" > </asp:Label> </div> </form> </body>
</html> http://asp-net-example.blogspot.com/2009/12/ajax-asyncfileupload-how-to-use.html