hi guys, i have value in hdnField in form1.aspx .Iam assigning value to hiddenfield in javascript.I want to get that value in aspx.vb in another form,form2.aspx.Can anybody help
I think your concept of session is wrong. Session is a server-side object, and javascript runs on the client, so you can not directly assign that value to a session. You can, instead, use some AJAX to send it to the server and then add code in the server so the value is assigned.
Hm... you have to think about the difference between serverside and clientside first... You cant directly access changes you made in the client on the serverside, because you once send a request to server, as a response you get the site diplayed in your browser. As soon as you recieve the request, the server is finished and cant access the site anymore. Its like a letter you send away. As soon as you put it into the mailbox, you cant make changes anymore. But you could post a new request to the server and add POST or GET peremeters. These can be accessed by the server. The way you send the request doesnt matter... you can send a request using AJAX or simply reload the page.
If your Form1.aspx submits to Form2.aspx, then you have atleast a few ways to access the value of form fields (including Hidden fields):
The Request.Form property exposes a
NameValueCollection
containing all submitted form field names as Keys and their values as Values. You could use the syntaxRequest.Form["fieldName"]
to access the value.If this is ASP.NET 2+ and you used the Cross-page posting technique, you will be able to access field values in the previous page using the
PreviousPage
property of the Page.If you use
Server.Transfer
, you can access values using the CurrentHttpContext
.
If you need more info, you should take a look at Passing values between pages in ASP.NET.