<html>
<script language="VB" runat="server">
Sub Page_Load(Sender As Object, E As EventArgs)
Dim RandomGenerator As Random
RandomGenerator = New Random(DateTime.Now.Millisecond)
Dim RandomNum As Integer
RandomNum = RandomGenerator.Next(0, 3)
Select RandomNum
Case 0:
Name.Text = "Scott"
Case 1:
Name.Text = "Fred"
Case 2:
Name.Text = "Adam"
End Select
AnchorLink.NavigateUrl = "controls_navigationtarget_vb.aspx?name=" & System.Web.HttpUtility.UrlEncode(Name.Text)
End Sub
</script>
<body>
<h3><font face="Verdana">Performing Page Navigation (Scenario 1)</font></h3>
<p>
This sample demonstrates how to generate a HTML Anchor tag that will cause the client to
navigate to a new page when he/she clicks it within the browser.
<p>
<hr>
<p>
<asp:hyperlink id="AnchorLink" font-size=24 runat=server>
Hi <asp:label id="Name" runat=server/> please click this link!
</asp:hyperlink>
</body>
</html>
执行页面导航(第二种情况)
并非所有的页面导航都由客户端的超级链接发起。ASP.NET页面开发者调用Response.Redirect(url)方法也可以发起客户端页面的重定向或导航。这种情况典型发生在真正进行导航之前,服务器端需要验证客户端的输入信息的时候。
下面的例子演示了如何使用Response.Redirect方法把参数传递到另外一个目标页面。它还演示了如何在目标页面上简单地获取这些参数。
<html>
<script language="VB" runat="server">
Sub EnterBtn_Click(Sender As Object, E As EventArgs)
If Not (Name.Text = "")
Response.Redirect("Controls_NavigationTarget_vb.aspx?name=" & System.Web.HttpUtility.UrlEncode(Name.Text))
Else
Message.Text = "Hey! Please enter your name in the textbox!"
End If
End Sub
</script>
<body>
<h3><font face="Verdana">Performing Page Navigation (Scenario 2)</font></h3>
<p>
This sample demonstrates how to navigate to a new page from within a <asp:button> click event, passing a <asp:textbox> value as a querystring argument (validating first that the a legal textbox value has been specified).
<p>
<hr>
<form action="controls6.aspx" runat=server>
<font face="Verdana">Please enter your name:
<asp:textbox id="Name" runat=server/>
<asp:button text="Enter" Onclick="EnterBtn_Click" runat=server/>
<p>
<asp:label id="Message" forecolor="red" font-bold="true" runat=server/>
</font>
</form>
</body>
</html>
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




