简体   繁体   中英

Accessing Hidden Field value from a different webpage

I have stored a string value in a hidden field of a page. How to access it from a different webpage?

You have two options.

a. Putting that string value in a Session.

  string value="value"; Session["myValue"] = value; 

b. Transmitting that value in the url.

 string value="value";
 Response.Redirect("./Mypage.aspx?value="+value);

On the page that contains the hidden value, you could post that form to the other page and get the value from this.Request.Form["hidden-field"].

Is that the sort of answer you are looking for? Maybe more details would help.

Good luck!

If you don't mind using jQuery, and as long as the pages are on the same domain, then you can do it with the .load() method. This method basically does a GET request to the page

Page with hidden field

<div id="hiddenValue">Value</div>

Page you're calling from

$('#newDiv').load('path/to/page.aspx #hiddenValue');

additional notes:

  • Due to browser security restrictions, most "Ajax" requests are subject to the same origin policy ; the request can not successfully retrieve data from a different domain, subdomain, or protocol.

If they are on different domains then your only other options are:

  • Query Strings

  • Sessions

references:

You can also use cookies to transfer the value across pages. May be you would want to read this piece of article to know more about the state management. Do read it. Will definitely gonna help you. You can decide what you want to use after reading this.

Hope it helps you. http://www.codeproject.com/KB/vista/ASPNet_State_Management.aspx

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM