PreviousPage = null in the cross message

I am trying to transfer mail data from one page to the next, but PreviousPage is always zero.

This is what I have on the original page (inside the update panel)

<asp:Button ID="mmGo" runat="server" Text="Merge" PostBackUrl="~/Default2.aspx?action=merge"/>

Then on the next page I:

<%@ 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>

... and in the .cs file:

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!";
    }
}

Any ideas why the previous step is always zero?

+3
source share
2 answers

The property returns the page that sent control to this page using . PreviousPageServer.Transfer

If the current page is displayed as a result of a direct request (rather than transfers or intersections from another page), the PreviousPage property contains null.

+5
source

... ... , postbackurl, response.redirect. postbackurl, , ... ,

http://www.youtube.com/watch?v=P1AqBtOYOMI

postbackurl Response.Redirect?

PostBackURL . Response.Redirect ,

+2

Source: https://habr.com/ru/post/1790462/


All Articles