ComboBoxChangeDataSource.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
string[] RedColors = { "Red", "IndianRed", "DarkRed", "Crimson", "Magenta" };
ComboBox1.DataSource = RedColors;
ComboBox1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
string[] BlueColors = { "Blue", "DodgerBlue", "SkyBlue", "DarkBlue", "CornFlowerBlue" };
ComboBox1.DataSource = BlueColors;
ComboBox1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ajax ComboBox - How to set change ComboBox data source programmatically in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
ASP.NET Ajax ComboBox - How to set change ComboBox
<br /> data source programmatically in asp.net
</h2>
<hr width="525" align="left" color="Pink" />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ComboBox
ID="ComboBox1"
runat="server"
DropDownStyle="DropDown"
AutoCompleteMode="None"
CaseSensitive="false"
RenderMode="Block"
AutoPostBack="false"
Font-Names="Comic Sans MS"
Font-Size="Large"
ForeColor="SeaGreen"
>
</asp:ComboBox>
<br /><br /><br />
<br /><br /><br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Data Source Red Type Colors"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
<asp:Button
ID="Button2"
runat="server"
OnClick="Button2_Click"
Text="Data Source Blue Type Colors"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Button1_Click(object sender, EventArgs e)
{
string[] RedColors = { "Red", "IndianRed", "DarkRed", "Crimson", "Magenta" };
ComboBox1.DataSource = RedColors;
ComboBox1.DataBind();
}
protected void Button2_Click(object sender, EventArgs e)
{
string[] BlueColors = { "Blue", "DodgerBlue", "SkyBlue", "DarkBlue", "CornFlowerBlue" };
ComboBox1.DataSource = BlueColors;
ComboBox1.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Ajax ComboBox - How to set change ComboBox data source programmatically in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:DarkBlue; font-style:italic;">
ASP.NET Ajax ComboBox - How to set change ComboBox
<br /> data source programmatically in asp.net
</h2>
<hr width="525" align="left" color="Pink" />
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:ComboBox
ID="ComboBox1"
runat="server"
DropDownStyle="DropDown"
AutoCompleteMode="None"
CaseSensitive="false"
RenderMode="Block"
AutoPostBack="false"
Font-Names="Comic Sans MS"
Font-Size="Large"
ForeColor="SeaGreen"
>
</asp:ComboBox>
<br /><br /><br />
<br /><br /><br />
<asp:Button
ID="Button1"
runat="server"
OnClick="Button1_Click"
Text="Data Source Red Type Colors"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
<asp:Button
ID="Button2"
runat="server"
OnClick="Button2_Click"
Text="Data Source Blue Type Colors"
Height="45"
Font-Bold="true"
ForeColor="DodgerBlue"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment