I have stored a string value in a hidden field of a page. How to access it from a different webpage?
4 Answers
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);

- 1,014
- 5
- 25
- 42
-
value of the string is of length 1300, will this not become too large to send through session? – Karthik Mar 30 '11 at 11:35
-
@Karthik: No, the session is capable of that – citronas Mar 30 '11 at 12:34
-
@Karthik: I don't think there is a max on session variable lengths. http://stackoverflow.com/questions/1755348/what-is-the-maximum-size-a-session-variable-can-hold – jon3laze Mar 31 '11 at 01:49
-
a 1300 length string it's a quite small string – Jeff Norman Mar 31 '11 at 10:35
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!

- 6,869
- 3
- 32
- 52
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:

- 3,188
- 6
- 36
- 69
-
is it not possible to do this without using jquery? the pages are in the same domain..... – Karthik Mar 30 '11 at 12:48
-
Oh you definitely can, it would be through Sessions or Query Strings tho. The easiest is probably Query Strings, but that's dependent on whether the info needs to be private or not. – jon3laze Mar 30 '11 at 18:12
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

- 214
- 3
- 19