How to get the value of a hidden field in another form

IIhave value in hdnField in form1.aspx. I am assigning a value to hdnfield in javascript. I want to get this value in aspx.vb in another form, form2.aspx. How can i do this?

0


a source to share


3 answers


If your Form1.aspx is submitted to Form2.aspx, you have at least several ways to access the value of the form fields (including hidden fields):

  • The Request.Form property provides a NameValueCollection

    containing all the form field names as keys and their values ​​as values. You can use syntax Request.Form["fieldName"]

    to access the value.

  • If it's ASP.NET 2+ and you've used the multi-page wiring technique, you should be able to access the field values ​​on the previous page using the PreviousPage

    page property .

  • If you are using Server.Transfer

    , you can access the values ​​using Current HttpContext

    .



If you need more information, you should take a look at Passing values ​​between pages in ASP.NET .

+2


a source


I think your concept of session is wrong. Session is a server-side object and javascript is executed on the client, so you cannot directly assign this value to the session. Instead, you can use AJAX to post to the server and then add code on the server to assign the value.



+1


a source


Hmm ... you need to think about the difference between servers and clients first ... You cannot directly access the changes you made on the client on the server because you are sending the request to the server as the response you receive in your browser. Once you receive the request, the server will shut down and will no longer be able to access the site. It's like a letter that you send. Once you put it in the mailbox, you can no longer make changes. But you can send a new request to the server and add POST or GET peremeters. Access to them is possible by the server. The way the request is sent doesn't matter ... you can send the request with AJAX or just reload the page.

0


a source







All Articles