PROGRAM TO LINK TO DESIRED PAGE USING RADIO BUTTON

DEFAULT.ASPX FILE:

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <p> <asp:RadioButtonList ID="radiobuttonlist1" runat ="server" >
    <asp:listItem Value ="Google">Google</asp:listItem>
    <asp:ListItem Value ="Yahoo">Yahoo</asp:ListItem>
    <asp:ListItem  Value ="Bing">Bing</asp:ListItem>
    </asp:RadioButtonList>&nbsp;</p>
        <p>
            <asp:Button ID="Button1" runat="server" Text="Submit" Width="96px" />&nbsp;</p>
        <p>
        </p>
   
    </div>
    </form>
</body>

</html>

DEFAULT.ASPX.VB FILE:


Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If (radiobuttonlist1.SelectedValue.EndsWith("Google")) Then
            Response.Redirect("http://www.google.com")
        ElseIf (radiobuttonlist1.SelectedValue.EndsWith("Yahoo")) Then
            Response.Redirect("http://www.Yahoo.com")
        ElseIf (radiobuttonlist1.SelectedValue.EndsWith("Bing")) Then
            Response.Redirect("http://www.Bing.com")
        Else
            MsgBox("Please Select a website")
        End If
    End Sub

End Class


No comments:

Post a Comment