radio_button.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="radio_button.aspx.cs" Inherits="our_program.radio_button" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<center><h1>radio button</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:RadioButton ID="rbn1" runat="server" GroupName="radio" Text="first radio button" />
<br />
<asp:RadioButton ID="rbn2" runat="server" GroupName="radio" Text="second radio button"/>
<br />
<asp:RadioButton ID="rbn3" runat="server" GroupName="radio" Text="third radio button"/>
<br />
<asp:Button ID="btn" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:Label ID="lbl" runat="server" Text="selected text will shown here"></asp:Label>
</div>
</center>
</form>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="radio_button.aspx.cs" Inherits="our_program.radio_button" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<center><h1>radio button</h1></center>
</head>
<body>
<form id="form1" runat="server">
<center>
<div>
<asp:RadioButton ID="rbn1" runat="server" GroupName="radio" Text="first radio button" />
<br />
<asp:RadioButton ID="rbn2" runat="server" GroupName="radio" Text="second radio button"/>
<br />
<asp:RadioButton ID="rbn3" runat="server" GroupName="radio" Text="third radio button"/>
<br />
<asp:Button ID="btn" runat="server" Text="Button" onclick="Button1_Click" />
<br />
<asp:Label ID="lbl" runat="server" Text="selected text will shown here"></asp:Label>
</div>
</center>
</form>
</body>
</html>
radio_button.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace our_program
{
public partial class radio_button : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
if (rbn1.Checked == true)
{
lbl.Text = "Your selected radio button is : " + rbn1.Text;
}
if (rbn2.Checked == true)
{
lbl.Text = "Your selected radio button is : " + rbn2.Text;
}
if (rbn3.Checked == true)
{
lbl.Text = "Your selected radio button is : " + rbn3.Text;
}
}
}
}
No comments:
Post a Comment