Sunday, 21 October 2012

Radio Button with page load event - ASP.NET Toolbox



here the code below(.aspx)

<%@ 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, EventArgs e)
    {
        if (RadioButton1.Checked == true)
            Label1.Text = RadioButton1.Text;
        else if (RadioButton2.Checked == true)
            Label1.Text = RadioButton2.Text;
    }

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>

        <br />
        <asp:RadioButton ID="RadioButton1" runat="server" AutoPostBack="True"
            GroupName="gender" Text="Male" />
&nbsp;&nbsp;&nbsp;&nbsp;
        <asp:RadioButton ID="RadioButton2" runat="server" AutoPostBack="True"
            GroupName="gender" Text="Female" />
        <br />
        <br />
        You have selected:&nbsp;
        <asp:Label ID="Label1" runat="server"></asp:Label>
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />
        <br />

    </div>
    </form>
</body>
</html>

No comments:

Post a Comment

Tech N Science © 2013