简体   繁体   中英

I paste value to textbox by jquery but i can't get this value from behind code

There are 3 asp:Textbox Using keyup in jquery to paste value to 3th asp:TextBox from 2 asp:TextBox before. (asp:Textbox 1 + asp:Textbox 2)

<asp:TextBox runat="server" ID="Total" CssClass="form-control"></asp:TextBox>

ex:

result = parseFloat(txt1) + parseFloat(txt2) 
$('input[id*=Total]').val(result);

in view: txt3 is 10

But in behind code I can't get value from 3th asp:TextBox

Your asp element should have runat="server" so that it can be referenced from code behind.

Note that when you use runat="server" the id is auto-generated so you need to specify the clientIDMode to make it static .

<asp:TextBox ID="txtBox" runat="server" ClientIDMode="Static"></asp:TextBox>

Also, if you don't want ClientIDMode to be static you can still reference the asp Element like following:

$('#<%=txtBox.ClientID%>').xxx();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM