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:
http://api.jquery.com/load/
http://www.java2s.com/Code/ASP/Request/GetquerystringfromRequestC.htm
http://msdn.microsoft.com/en-us/library/ms178581.aspx
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
精彩评论