1. Get ASP. Net Value in JS
(1) obtain the value of the server control
VaR S = Document. getelementbyid ("textbox1"). value; // obtain the text value of textbox1
(2) obtain the global variable value
Define protected string st before page_load;
In the page_load () method, assign ST = "Haha ";
In JS, write and obtain
VaR S = "<% = sT %> ";
--------------------------------------------------------------------------------
2. Obtain JS values in ASP. NET.
We recommend that you use the <asp: hiddenfield id = "hiddenfield1" runat = "server"/> control.
Add in JSCode
Document. getelementbyid ("hiddenfield1"). value = 'wind In the Wind ';
In the background code, you can directly use hiddenfield1.value to obtain
Use <input type = "hidden" id = "Leslie" runat = "server"/>
In the background code, you can directly use Leslie. Value to obtain
PS:
You can also use the <input type = "hidden" id = "Leslie" name = "Leslie"> Method
Use request. Form. Get ("Leslie"); // in background operations to obtain the value of name = "Leslie"