Solve the problem that the modified value cannot be obtained in the background after the server-side control value is modified using Js.
The project has a small function to modify the value of a server tag in JS, such as document. getelementbyid ("lblclothindex "). innerhtml = result; (for example, from "1" to "2"), but in the background through this. lblclothindex. text returns the old value "1. Later, we found that the latest value can be obtained by calling the hidden control method,CodeAs follows:
1. add a hidden Control <asp: hiddenfield id = "hiddenfield1" runat = "server"/> 2. when JS is used to assign a value to the server tag, it also assigns a document value to the hidden control. getelementbyid ("hiddenfield1 "). value = result; 3. use this. the hiddenfield1.value code obtains the latest value.
Original article: http://www.cnblogs.com/gossip/archive/2010/03/26/1697203.html
ASP. net cannot obtain a value modified by JS: <select id = "ddname" name = "ddname" runat = "server" Disabled = "disabled" onchange = "show (this) "> <option> select a Category </option> </SELECT> one lable: <asp: label id = "lbname" runat = "server" text = "label"> </ASP: Label>
Function show (a) {var sel = document. getelementbyid ("<% = lbname. clientid %> "); SEL. innerhtml = "<span style = 'font-size: 8pt; color: red; '>" +. value + "</span>"; document. getelementbyid ("hidd "). value = SEL. innerhtml ;}
I want to obtain the selected select value. No matter whether it is through request. Form ["ddname"] or by assigning a value to a hidden domain, the background will not be able to get it. Why? Question added:
Select is the first data to be bound through js xmlhttp. Your select value is assigned on the client, and viewstate is not saved. The server cannot naturally obtain the second. What controls are used to hide the domain? If it is hiddenfield, the client value can be obtained on the server.
Original: http://zhidao.baidu.com/question/292323835.html