Introduction:
Here I will explain RadioButton ASP.NET.
Description
The RadioButton control is used to display a radio button.
Example
<%@ 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 RadioButton_CheckedChanged(object sender, System.EventArgs e) { if (RadioButton1.Checked == true) { Label1.Text = "You choose: " + RadioButton1.Text; } else { Label1.Text = "You choose: " + RadioButton2.Text; } }
</script>
<html
xmlns="http://www.w3.org/1999/xhtml">
<head
id="Head1" runat="server"> <title>RadioButton</title>
</head>
<body>
<form id="form1" runat="server"> <div> <h2 style="color: Navy"> RadioButton Example: OnCheckedChanged</h2> <asp:label id="Label1" runat="server" font-bold="true" forecolor="OliveDrab" font-size="Large"> </asp:label> <br /> <br /> <asp:label id="Label2" runat="server" font-bold="true" forecolor="Crimson" text="Favorite Control?"> </asp:label> <br /> <asp:radiobutton id="RadioButton1" runat="server" text="ValidationSummary" groupname="Controls" oncheckedchanged="RadioButton_CheckedChanged" autopostback="true" /> <asp:radiobutton id="RadioButton2" runat="server" text="CompareValidator" groupname="Controls" oncheckedchanged="RadioButton_CheckedChanged" autopostback="true" /> </div> </form>
</body>
</html>
|
0 comments :
Post a Comment