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?

Chris1804505
  • 97
  • 1
  • 10

1 Answers1

0

This page contains the answer! : http://www.codingwith.net/2008/01/using-previouspage-property-with.html

(Don't forget your using statement if you intend to access pages in another folder of the solution, intellesense will probably generate it for you though)

MY Code here:

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

                }
Chris1804505
  • 97
  • 1
  • 10