在ASP.NET网页发布中,如何处理‘PreviousPage’属性为null的情况?
- 内容介绍
- 文章标签
- 相关推荐
本文共计348个文字,预计阅读时间需要2分钟。
我在尝试将数据从一页传递到下一页,但PreviousPage总是等于null。这就是我在原始页面中的内容(在更新页面内)+asp:Button ID=mmGo runat=server Text=Merge PostBackUrl=~\Default2.aspx
我正在尝试将帖子数据从一个页面传递到下一个页面,但PreviousPage总是等于null.这就是我在原始页面中的内容(在更新面板内)
)
<asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/>
然后在下一页我有:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <%@ PreviousPageType VirtualPath="~/Default.aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form> </body> </html>
…并在.cs文件中:
protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { string action = Request.QueryString["action"]; if (action == "merge") { UpdatePanel SourceControl = (UpdatePanel)PreviousPage.FindControl("UpdatePanel1"); HiddenField SourceTextBox = (HiddenField)SourceControl.FindControl("txtListIDs"); if (SourceTextBox != null) { Label1.Text = SourceTextBox.Value; } } } else { Label1.Text = "page is not cross page post back!"; } }
任何想法为什么PreviousPage总是等于null?
PreviousPage property使用Server.Transfer返回将控件发送到此页面的页面.
If the current page is being rendered as a result of a direct request (not a transfer or cross-post from another page), the PreviousPage property contains null.
本文共计348个文字,预计阅读时间需要2分钟。
我在尝试将数据从一页传递到下一页,但PreviousPage总是等于null。这就是我在原始页面中的内容(在更新页面内)+asp:Button ID=mmGo runat=server Text=Merge PostBackUrl=~\Default2.aspx
我正在尝试将帖子数据从一个页面传递到下一个页面,但PreviousPage总是等于null.这就是我在原始页面中的内容(在更新面板内)
)
<asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/>
然后在下一页我有:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> <%@ PreviousPageType VirtualPath="~/Default.aspx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> </div> </form> </body> </html>
…并在.cs文件中:
protected void Page_Load(object sender, EventArgs e) { if (PreviousPage != null) { string action = Request.QueryString["action"]; if (action == "merge") { UpdatePanel SourceControl = (UpdatePanel)PreviousPage.FindControl("UpdatePanel1"); HiddenField SourceTextBox = (HiddenField)SourceControl.FindControl("txtListIDs"); if (SourceTextBox != null) { Label1.Text = SourceTextBox.Value; } } } else { Label1.Text = "page is not cross page post back!"; } }
任何想法为什么PreviousPage总是等于null?
PreviousPage property使用Server.Transfer返回将控件发送到此页面的页面.
If the current page is being rendered as a result of a direct request (not a transfer or cross-post from another page), the PreviousPage property contains null.

