<%@ Page Language="C#" %>
<!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, System.EventArgs e)
{
if(RadioButton1.Checked == true)
{
Label1.Text = "Checked: " + RadioButton1.Text;
}
else if (RadioButton2.Checked == true)
{
Label1.Text = "Checked: " + RadioButton2.Text;
}
else
{
Label1.Text = "Checked None";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to get RadioButton checked status programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Green">RadioButton Example: Checked Status</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
ForeColor="Red"
Font-Size="Larger"
>
</asp:Label>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Font-Bold="true"
ForeColor="DodgerBlue"
Text="Favorite Color?"
>
</asp:Label>
<br />
<asp:RadioButton
ID="RadioButton1"
runat="server"
Text="GhostWhite"
GroupName="Colors"
/>
<asp:RadioButton
ID="RadioButton2"
runat="server"
Text="Fuchsia"
GroupName="Colors"
/>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="DarkOliveGreen"
Text="Get Checked Status"
OnClick="Button1_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
<!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, System.EventArgs e)
{
if(RadioButton1.Checked == true)
{
Label1.Text = "Checked: " + RadioButton1.Text;
}
else if (RadioButton2.Checked == true)
{
Label1.Text = "Checked: " + RadioButton2.Text;
}
else
{
Label1.Text = "Checked None";
}
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to get RadioButton checked status programmatically</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Green">RadioButton Example: Checked Status</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
ForeColor="Red"
Font-Size="Larger"
>
</asp:Label>
<br /><br />
<asp:Label
ID="Label2"
runat="server"
Font-Bold="true"
ForeColor="DodgerBlue"
Text="Favorite Color?"
>
</asp:Label>
<br />
<asp:RadioButton
ID="RadioButton1"
runat="server"
Text="GhostWhite"
GroupName="Colors"
/>
<asp:RadioButton
ID="RadioButton2"
runat="server"
Text="Fuchsia"
GroupName="Colors"
/>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="DarkOliveGreen"
Text="Get Checked Status"
OnClick="Button1_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment