Accessing ViewState from image rendering aspx page

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
 
T

Tommy

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,
 
J

Jeronimo Bertran

Tommy

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

Thanks again
 
J

Jacob Yang [MSFT]

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.
 
J

Jeronimo Bertran

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
 
J

Jacob Yang [MSFT]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top