Redirect a URL (C#) : ReDirect « Response « ASP.Net






Redirect a URL (C#)

<%@ Page Language="c#" %>
<script Language="c#" runat="server">
  void Page_Load(object source, EventArgs e)
  {
    if (!(IsPostBack))
    { 
      MyButton.Text = "OK";
      MyDropDownList.Items.Add("http://www.java2s.com");
      MyDropDownList.Items.Add("http://www.java2s.com");
    }
  }
  public void Click (object sender, EventArgs e)
  {
    Response.Redirect(MyDropDownList.SelectedItem.Text);
  }
</script>

<html>
  <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>

           
       








Related examples in the same category

1.Redirect page to another URL (vb.net)