Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I guess the first thing you need to understand is that ASP.NET is stateless. That means that no data is "saved" between pages. What the <code>PreviousPage</code> property does is it allows the request information persist through the use of a <code>Transfer</code> method, and the request information will be the GET or POST variables.</p> <p>IMHO, the best way to do what you desire, is to have a shared public class that is not related to either page, and have a public function for getting the <code>SqlConnection</code>. Remember though, it is stateless, so you will have to create the connection each time.</p> <p>Another alternative would be to save the dbConnection in the session (which I don't recommend, since it is possible to view the session information).</p> <p>Otherwise, you can't have a variable persist with information between pages. Thats what is means to be stateless.</p> <p>ALSO, for <code>PreviousPage</code>, keep in mind that it is creating an instance of <code>System.Web.UI.Page</code>, not an instance of <code>Protocol</code>. That means public properties won't exist from <code>Protocol</code>, only native features of <code>Page</code> will be there.</p> <p><b>edit</b></p> <p>From <a href="http://msdn.microsoft.com/en-us/library/ms178139.aspx" rel="nofollow">msdn</a></p> <p>Note</p> <p>Properties on the source page that are created primarily to expose values for cross-page posting are usually read-only properties. Although the source page can contain public read/write properties, setting a source page property from the target page property generally has no purpose, because the value will not be persisted.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload