gpt4 book ai didi

asp.net - PreviousPage = 在跨页发布中为空

转载 作者:行者123 更新时间:2023-12-04 23:31:13 25 4
gpt4 key购买 nike

我试图将帖子数据从一页传递到下一页,但 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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://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.

关于asp.net - PreviousPage = 在跨页发布中为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4922513/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com