Cross-page PostBack passing JavaScript variable value (pass JS variable to another page)

Source: Internet
Author: User

When you need to pass the value from an HTML page to an ASP. NET page, you can use it. It is very basic and saved for beginners who have never learned ASP to do so.

 

 

< Html >
< Head >
< Title > HTML start page </ Title >
</ Head >
< Body >
  < Form ID = "Form1" Method = "Post" Action = "Webform1.aspx" >
< Input Type = "Text" ID = "Yourtextbox" Name = "Yourtextbox" Value = "This is the HTML page textbox value"   />
< Input Type = "Hidden" ID = "Yourhiddenelement" Name = "Yourhiddenelement" Value = "This is the HTML page hidden element value"   />
< Input Type = "Submit" Value = "Go"   />
  </ Form >
</ Body >
</ Html >

 

 

Private   Void Page_load ( Object Sender, system. eventargs E)
{
  If ( ! This . Ispostback)
{
String Textboxvalue = Request [ " Yourtextbox " ];
String Hiddenelementvalue = Request [ " Yourhiddenelement " ];
This . Response. Write ( " Textboxvalue: "   + Textboxvalue +   " <Br> " );
This . Response. Write ( " Hiddenelementvalue: "   + Hiddenelementvalue +   " <Br> " );
}
}

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.