Monday 3 October 2011

Redirect page to another URL (vb.net)


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


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head><title >roja</title></head>
  <body>
    <form id="WebForm1" method="post" runat="server">
      <asp:DropDownList id="MyDropDownList" runat="server"/>
      <asp:button id="MyButton" runat="server" OnClick="Click" Text=""/>
    </form>
  </body>
</html>



Partial Class rojas
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        MyButton.Text = "OK"
        MyDropDownList.Items.Add("http://www.rojasamala.blogspot.com")
        MyDropDownList.Items.Add("http://www.roja-dotnet.blogspot.com")
        MyDropDownList.Items.Add("http://www.rojasamala-sqlserver.blogspot.com")

    End Sub

    Protected Sub Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyButton.Click
        Response.Redirect(MyDropDownList.SelectedItem.Text)
    End Sub
End Class