ASP.NET 4.00 Losing Public Property Values When clicking button to display next page?
Posted on 2014-01-21
I have a page with a public property that stores the ID of the record I am displaying. When I click a button to move off that page I want to read the value of that property so that I can use it to get the data on the next page. What I am finding is that the property holds the ID right up to the moment I click the button that triggers the switch to the next page. I am using Server.Transfer("frmIncidentReportP3.aspx", True) in the click event of the button that transfers me from the first to the second page.
In the top of the new page I have this:
<%@ PreviousPageType VirtualPath="~/frmIncidentReportP2.aspx" %>
And in the Page_Load of the new page I have:
If Not IsNothing(PreviousPage) Then
If PreviousPage.IncidentReportID > 0 Then
Me.IncidentReportID = PreviousPage.IncidentReportID
The issue is that just prior to clicking the button IncidentReportID in "frmIncidentReportP2.aspx" holds the ID value, the moment I click the button it zeros so that by the time I get to the new page its value is lost.
What am I missing, why does the click of the button on the first page cause the Public property to instantly lose its value?