<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadioButton.aspx.cs" Inherits="RadioButtonListEx.RadioButton" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head id="Head1" runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"> <asp:ListItem Selected="True">Hello!</asp:ListItem> <asp:ListItem>First Time!</asp:ListItem> <asp:ListItem>second Time!</asp:ListItem> <asp:ListItem>Third Time!</asp:ListItem> </asp:RadioButtonList></div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:TextBox runat="server" id="txtCount"/> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="RadioButtonList1" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace RadioButtonListEx { public partial class RadioButton : System.Web.UI.Page { static int count = 0; protected void Page_Load(object sender, EventArgs e) { } protected void RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { count = count + 1; Label1.Text = RadioButtonList1.SelectedValue; txtCount.Text = count.ToString(); } } }
Mark This Response as Answer -- Chandu http://www.dotnetfunda.com/images/dnfmvp.gif
Login to post response