Click to See Complete Forum and Search --> : how can I retrieve values of variables from one asp page to another??


GabyGirl
February 17th, 2003, 08:40 PM
Hello, Is there anyway one can access variables from one asp page to another? If there is not, how can one access those variables without having to use a form?

DSJ
February 18th, 2003, 02:34 PM
You can either put them in the querystring or create session variables to hold the information.

mikescham
February 18th, 2003, 06:00 PM
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconpassingservercontrolvaluesbetweenpages.asp

Don't worry about the page template @reference directives. All you need to do is get a handle to IContextHandler in the code behind of the target page and cast it to the page that is sending the values.

You'll see what I'm talking about after you read this article. It sounds complicated but its really easy and not as annoying as session variables and query string parameters.

Farhad
February 19th, 2003, 05:33 AM
Hi Mike

I applied your suggested technique, it worked.

But when i try to access the second page by providing its url
it gives following error message.
...................................................................

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:


if (!IsPostBack)
{
fp=(FormOne) Context.Handler;
}

mikescham
February 19th, 2003, 10:10 AM
Try this

if (!IsPostback) {

if (Context.Handler is FormOne) {
fp = (FormOne)Context.Handler;
}


}

Farhad
February 19th, 2003, 11:16 PM
Thankyou Mike its working now.