Beruflich Dokumente
Kultur Dokumente
NET Example
By Saiful Alam
<script runat="server">
<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
<script runat="server">
<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
<script runat="server">
<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
<script runat="server">
}
</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
<script runat="server">
<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
<script runat="server">
<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
<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 = "";
<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#" %>
<script runat="server">
private int[,] numbers = {{100,150},{200,250},{300,350},{400,450},{500,550}
};
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
SqlConnection MyConnection;
SqlCommand MyCommand;
SqlDataReader MyReader;
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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
SqlConnection MyConnection;
SqlCommand MyCommand;
SqlDataAdapter MyAdapter;
DataTable 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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
SqlConnection MyConnection;
SqlCommand MyCommand;
SqlDataReader MyReader;
SqlParameter ProductNameParam;
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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
int i = 0;
while (i < 11) {
i+=1;
Label1.Text += i + ", ";
}
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
for (int i = 1; i < 11; i++) {
Label1.Text += i + ", ";
}
<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
<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
<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
<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;
<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
<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();
<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
<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.Abs(9);
Label1.Text += "<br/>Math.Abs(9) : " + 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
<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
<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
<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);
}
}
}
<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
<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();
}
}
<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
<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
<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
<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>
</div>
</form>
</body>
</html>
http://asp-net-example.blogspot.com/2009/08/how-to-change-meta-element-in-aspnet.html
Example 31
<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
</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
<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
</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
</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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<script runat="server">
protected void CheckBox1_CheckChanged(object sender, System.EventArgs e) {
<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
<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
<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
<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
<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
<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
<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 />
<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 />
<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
<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
<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);
}
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
<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);
}
}
<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
<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);
<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
<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);
<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
<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
<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
<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
<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
<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
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
<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
<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;
}
}
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if (!this.IsPostBack)
{
TextBox1.Text += Request.PhysicalApplicationPath + "HP2133.jpg";
}
}
<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
<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
<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
<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
<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
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!Page.IsPostBack){
SqlConnection mySqlConnection;
SqlCommand mySqlCommand;
SqlDataReader mySqlDataReader;
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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!Page.IsPostBack){
SqlConnection myConnection;
SqlCommand myCommand;
SqlDataAdapter myAdapter;
DataTable 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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!Page.IsPostBack){
DropDownListDataBind();
}
}
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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!";
}
}
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e){
if(!Page.IsPostBack){
ListBoxDataBind();
}
}
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!Page.IsPostBack){
DropDownListDataBind();
}
}
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if(!Page.IsPostBack){
ListBox1.DataSource = Roles.GetAllRoles();
ListBox1.DataBind();
}
}
<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
<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();
}
}
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
Session["CityID"] = "10";
Session["CityName"] = "Paris";
<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
<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
<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
<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
<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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
Session["Email"] = "test@test.com";
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
<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");
<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
<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
<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
<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
<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";
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
<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
<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
<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
<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
<script runat="server">
</script>
</div>
</form>
</body>
</html>
http://asp-net-example.blogspot.com/2009/08/how-to-handle-null-value-parameters-in.html
Example 152
</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
</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
<script runat="server">
protected void Page_Load(object sender, System.EventArgs e) {
if (!Page.IsPostBack) {
SqlConnection MyConnection;
SqlCommand MyCommand;
SqlDataReader MyReader;
SqlParameter ProductNameParam;
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
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e) {
<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#" %>
<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
<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
<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
<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);
<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
<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");
<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
<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! ");
<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
<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
<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
<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
<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
<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
<script runat="server">
private string[] colorArray = { "Red", "Green", "Yellow", "HotPink",
"SeaGreen" };
<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
<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
<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
<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
<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
<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 />
<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
<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 />
<script runat="server">
protected void Button1_Click(object sender, System.EventArgs e) {
Label1.Text = "You submited this name: " +
TextBox1.Text.ToString();
}
<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
<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>
</div>
</form>
</body>
</html>
http://asp-net-example.blogspot.com/2008/10/wizard-example-how-to-use-wizard.html
Example 179
</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
</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
</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
</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
</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
</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
</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
</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
</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
</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