RadioButton is a server control use to display option similar to checkbox.
RadioButton control supports the following properties
RadioButton Example
RadioButton control supports the following properties
RadioButton 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 btnSubmit_Click(object sender, EventArgs e)
{
if (rdlYes.Checked)
lblResult.Text = rdlYes.Text;
if (rdlNo.Checked)
lblResult.Text = rdlNo.Text;
if (rdlNone.Checked)
lblResult.Text = rdlNone.Text;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>RadioButton Example</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Did you like my website?
<ul>
<li>
<asp:RadioButton id="rdlYes" Text="Yes" GroupName="Source" Runat="server" />
</li>
<li>
<asp:RadioButton id="rdlNo" Text="No" GroupName="Source" Runat="server" />
</li>
<li>
<asp:RadioButton id="rdlNone" Text="None" GroupName="Source" Runat="server" />
</li>
</ul>
<asp:Button id="btnSubmit" Text="Submit" Runat="server" OnClick="btnSubmit_Click" />
<hr />
Answer: <asp:Label id="lblResult" Runat="server" />
</div>
</form>
</body>
</html>
Output:
No comments:
Post a Comment