Accessing ViewState from image rendering aspx page

  • Thread starter Thread starter Jeronimo Bertran
  • Start date Start date
J

Jeronimo Bertran

I have an aspx page that saves some information using the ViewState. This
page has an IMG META that uses a second aspx page to render the image.

<IMG src= "ImageRender.aspx">

I noticed that in the ImageRender.aspx, the "sender" parameter in the
Page_Load referes to the page that has the IMG tag.

The main page saves State information using the ViewState. Can this
information be accessed from the ImageRender.aspx?


Thanks

Jeronimo
 
The viewState is a private property of the Page object. However, you
can create a public property in the main page that access the
viewState. In your "ImageRender.aspx", you can access the viewState of
the main page through the public property.

Tommy,
 
Tommy

I created the public property but I still don't understand how to reference
the main page from the ImageRender.aspx.

Thanks again
 
Hi Jeronimo,

Based on my research and experience, the following article is useful to
you. Please refer to it carefully.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/
vbtskpassingvaluesbetweenwebformspages.asp
Passing Values Between Web Forms Pages
"...
There are many times when you will want to navigate from one page to
another and pass values from the first page to the second..."

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Jacob,

I read the article and it definately helps, however it talks about
invoking the second page using Server.Transfer("Webform2.aspx");


In my case, the second page is the src of an IMG tag...


<IMG src="Webform2.aspx">


I tried the following in the Webform2 but the assignment fails:


private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
WebForm1 sourcepage = (WebForm1) Context.Handler;
}
}

Thanks again,

Jeronimo



(e-mail address removed) (Jacob Yang [MSFT]) wrote in
 
Hi Jeronimo

Based on my research and experience, I would like to share the following
information with you.

When the first page is requested, the server only sends the tag for the
image, not the image itself. The browser sees the image tag and makes an
independent request for the image. Then the server receives the request for
the image, it does not know about the previous page request unless you
store information in the session object or in the image tag's query string.

We have run a test to see what the "sender" object contains in the page
that provides the image. It contained it's own page object, not the calling
page's object. Therefore, the sender object does not help.

I hope it helps.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top