Accessing ViewState from image rendering aspx page

Discussion in 'ASP .Net' started by Jeronimo Bertran, Nov 29, 2003.

  1. 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
     
    Jeronimo Bertran, Nov 29, 2003
    #1
    1. Advertisements

  2. Jeronimo Bertran

    Tommy Guest

    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, Nov 29, 2003
    #2
    1. Advertisements

  3. Tommy

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

    Thanks again
     
    Jeronimo Bertran, Nov 29, 2003
    #3
  4. 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.
     
    Jacob Yang [MSFT], Dec 1, 2003
    #4
  5. 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



    (Jacob Yang [MSFT]) wrote in
     
    Jeronimo Bertran, Dec 1, 2003
    #5
  6. 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.
     
    Jacob Yang [MSFT], Dec 4, 2003
    #6
  7. Jacob,

    Thanks again... ok, everything is clear.
     
    Jeronimo Bertran, Dec 4, 2003
    #7
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.