ASP.Net/Response/ReDirect — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
(нет различий)

Текущая версия на 11:54, 26 мая 2010

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.nfex.ru");
      MyDropDownList.Items.Add("http://www.nfex.ru");
    }
  }
  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>



Redirect page to another URL (vb.net)

<%@ Page Language="VB" %>
<script language="vb" runat="server">
   Sub Page_Load(Source As Object, E as EventArgs)
     If Not IsPostBack Then
       MyButton.Text = "OK"
       MyDropDownList.Items.Add("http://www.nfex.ru")
       MyDropDownList.Items.Add("http://www.nfex.ru")
       MyDropDownList.Items.Add("http://www.nfex.ru")
     End If
   End Sub
   Public Sub Click (ByVal sender As Object, ByVal e As System.EventArgs)
     Response.Redirect(MyDropDownList.SelectedItem.Text)
   End Sub
</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>