0

In ASP.net I have two similar pages that display summary information. I would like to pull from these pages a property value to display detailed information about the selected record in a detail page. I was successful in doing it for just one summary page using the @PreviousPageType reference.

    <%@ PreviousPageType VirtualPath="~/SOURCE1.aspx" %>

But It soon appeared that I needed another page as a feeder. Unfortunately from what I have read it seems that you cannot have multiple PreviousPageTypes

According to: http://msdn.microsoft.com/en-us/library/ms178139%28v=vs.100%29.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-6 I should be able to do something similar with reference:

    <%@ Reference VirtualPath="~/SOURCE1.aspx" %>

I'm not sure how to cast the page though as I'm not sure what 'SourcePage_Aspx is in the code below which incidentally is from the link above.

    SourcePage_aspx sourcePage;
    sourcePage = (SourcePage_aspx) PreviousPage;
    Label1.Text = sourcePage.CurrentCity;

I know that to use a reference you have to cast it but, how is this done? Could someone please point me in the correct direction?

4

1 回答 1

0

此页面包含答案!: http: //www.codingwith.net/2008/01/using-previouspage-property-with.html

(如果您打算访问解决方案的另一个文件夹中的页面,请不要忘记您的 using 语句,但 intellesense 可能会为您生成它)

我的代码在这里:

                if (Page.PreviousPage != null && Page.PreviousPage.IsCrossPagePostBack == true)
                {
                    //make sure to define reference directive on .aspx : <%@ Reference Page="~/SourcePage1.aspx" %>
                    if (PreviousPage is SourcePage1)
                    {
                        ViewState["SessionVariable"] = ((SourcePage1)PreviousPage).PropertyFromPreviousPage1;
                    }
                    //make sure to define reference directive on .aspx : <%@ Reference Page="~/SourcePage2.aspx" %>
                    if (PreviousPage is SourcePage2)
                    {
                        ViewState["SessionVariable"] = ((SourcePage2)PreviousPage).PropertyFromPreviousPage2;
                    }

                }
于 2013-03-06T13:51:06.740 回答