Radio button auto post back (C#)
<%@ Page Language="C#" %>
<script runat="server">
protected void RadioButton_CheckedChanged(object sender, EventArgs e)
{
RadioButton selectedRadioButton = (RadioButton)sender;
lblResult.Text = selectedRadioButton.Text;
}
</script>
<html>
<head>
<title>RadioButton AutoPostBack</title>
</head>
<body>
<form id="form1" runat="server">
<div>
How did you hear about our Website?
<ul>
<li>
<asp:RadioButton
id="rdlMagazine"
Text="Magazine Article"
GroupName="Source"
AutoPostBack="true"
OnCheckedChanged="RadioButton_CheckedChanged"
Runat="server" />
</li>
<li>
<asp:RadioButton
id="rdlTelevision"
Text="Television Program"
GroupName="Source"
AutoPostBack="true"
OnCheckedChanged="RadioButton_CheckedChanged"
Runat="server" />
</li>
<li>
<asp:RadioButton
id="rdlOther"
Text="Other Source"
GroupName="Source"
AutoPostBack="true"
OnCheckedChanged="RadioButton_CheckedChanged"
Runat="server" />
</li>
</ul>
<hr />
<asp:Label
id="lblResult"
Runat="server" />
</div>
</form>
</body>
</html>
Related examples in the same category