locked
Hidden Variable - Reading from ASPX page RRS feed

  • Question

  • I have defined an <asp:HiddenField on ASPX page and can set and read attributes to / from it on the silverlight side (from Page.xaml.cs).  My program sets the value of HiddenField then opens ASPX page with the following:

    HtmlPage.Window.Navigate(new System.Uri(sURI));

    Once the ASPX page is opened, if I try to get the value of the hiddenField from the ASPX.CS page I keep getting null (or empty string).  The code I'm using on ASPX.CS page to get the value of the HiddenField is:

    string sInput1 = hiddenVar.Value;    (where hiddenVar is the ID in <asp:HiddenField)

    HOW CAN THE VALUE IN THE HIDDEN FIELD BE ACCESSED FROM ASPX PAGE.  Thanks

    Wednesday, January 14, 2009 1:01 PM

Answers

  • I'm sure Window.Navigate is doing a GET on the page, which means you won't get the value of any form fields, since it isn't a POST (i.e. an ASP.NET postback). You can fill in the fields and then cause a postback to occur using javascript. See the doPostback() method, and check out the HTML/javascript bridge in Silverlight.

    Wednesday, January 14, 2009 2:41 PM
  • You can use just a querystring parameter as well.

     

    HtmlPage.Window.Navigate(string.Format("page.aspx?p={0}", value));

     

    Just an idea

    Wednesday, January 14, 2009 3:05 PM

All replies

  • I'm sure Window.Navigate is doing a GET on the page, which means you won't get the value of any form fields, since it isn't a POST (i.e. an ASP.NET postback). You can fill in the fields and then cause a postback to occur using javascript. See the doPostback() method, and check out the HTML/javascript bridge in Silverlight.

    Wednesday, January 14, 2009 2:41 PM
  • You can use just a querystring parameter as well.

     

    HtmlPage.Window.Navigate(string.Format("page.aspx?p={0}", value));

     

    Just an idea

    Wednesday, January 14, 2009 3:05 PM