// ToolBoxControls.xml //
<?xml version="1.0" encoding="utf-8" ?>
<StandardToolBox>
<Control Name="AdRotator" />
<Control Name="BulletedList" />
<Control Name="Button" />
<Control Name="Calendar" />
<Control Name="CheckBox" />
<Control Name="CheckBoxList" />
<Control Name="DropDownList" />
<Control Name="FileUpload" />
<Control Name="HiddenField" />
<Control Name="HyperLink" />
<Control Name="Image" />
<Control Name="ImageMap" />
<Control Name="ListBox" />
<Control Name="Literal" />
<Control Name="Localize" />
<Control Name="MultiView" />
<Control Name="View" />
<Control Name="Panel" />
<Control Name="PlaceHolder" />
<Control Name="RadioButton" />
<Control Name="RadioButtonList" />
<Control Name="Substitution" />
<Control Name="Table" />
<Control Name="TextBox" />
<Control Name="Wizard" />
<Control Name="XML" />
</StandardToolBox>
// Default.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>XmlDataSource Simple Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/ToolBoxControls.xml">
</asp:XmlDataSource>
<asp:Label ID="Label1" runat="server" Font-Size="Medium" ForeColor="Fuchsia">
</asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Text="Select your most favorite Standard ToolBox Control" Font-Size="Large" ForeColor="DarkRed">
</asp:Label>
<asp:RadioButtonList
ID="RadioButtonList1"
runat="server"
DataSourceID="XmlDataSource1"
DataMember="Control"
DataTextField="Name"
RepeatColumns="4"
AutoPostBack="true"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
// Default.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text ="Your favorite control: "+ RadioButtonList1.SelectedItem.Text.ToString();
}
}
<?xml version="1.0" encoding="utf-8" ?>
<StandardToolBox>
<Control Name="AdRotator" />
<Control Name="BulletedList" />
<Control Name="Button" />
<Control Name="Calendar" />
<Control Name="CheckBox" />
<Control Name="CheckBoxList" />
<Control Name="DropDownList" />
<Control Name="FileUpload" />
<Control Name="HiddenField" />
<Control Name="HyperLink" />
<Control Name="Image" />
<Control Name="ImageMap" />
<Control Name="ListBox" />
<Control Name="Literal" />
<Control Name="Localize" />
<Control Name="MultiView" />
<Control Name="View" />
<Control Name="Panel" />
<Control Name="PlaceHolder" />
<Control Name="RadioButton" />
<Control Name="RadioButtonList" />
<Control Name="Substitution" />
<Control Name="Table" />
<Control Name="TextBox" />
<Control Name="Wizard" />
<Control Name="XML" />
</StandardToolBox>
// Default.aspx //
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>XmlDataSource Simple Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:XmlDataSource ID="XmlDataSource1" runat="server"
DataFile="~/App_Data/ToolBoxControls.xml">
</asp:XmlDataSource>
<asp:Label ID="Label1" runat="server" Font-Size="Medium" ForeColor="Fuchsia">
</asp:Label>
<br /><br />
<asp:Label ID="Label2" runat="server" Text="Select your most favorite Standard ToolBox Control" Font-Size="Large" ForeColor="DarkRed">
</asp:Label>
<asp:RadioButtonList
ID="RadioButtonList1"
runat="server"
DataSourceID="XmlDataSource1"
DataMember="Control"
DataTextField="Name"
RepeatColumns="4"
AutoPostBack="true"
OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"
>
</asp:RadioButtonList>
</div>
</form>
</body>
</html>
// Default.aspx.cs //
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadioButtonList1_SelectedIndexChanged(object sender, System.EventArgs e)
{
Label1.Text ="Your favorite control: "+ RadioButtonList1.SelectedItem.Text.ToString();
}
}
// OUTPUT //
No comments:
Post a Comment