<%@ 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 Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
RadioButton1.Checked = true;
}
}
protected void Button1_Click(object sender, System.EventArgs e)
{
RadioButton1.Checked = false;
RadioButton2.Checked = false;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>How to unchecked RadioButton
programmatically
</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<h2 style="color:Navy">RadioButton
Example: Unchecked
</h2>
<asp:Label
ID="Label1"
runat="server"
Font-Bold="true"
ForeColor="Indigo"
Text="Favorite Color?"
>
</asp:Label>
<br />
<asp:RadioButton
ID="RadioButton1"
runat="server"
Text="LightBlue"
GroupName="Colors"
/>
<asp:RadioButton
ID="RadioButton2"
runat="server"
Text="LightCoral"
GroupName="Colors"
/>
<br /><br />
<asp:Button
ID="Button1"
runat="server"
ForeColor="Indigo"
Text="Unchecked RadioButton"
OnClick="Button1_Click"
Font-Bold="true"
/>
</div>
</form>
</body>
</html>
No comments:
Post a Comment