I am trying to pass the value of a variable from javascript to C#.
Here is the client side part:
<input type="text" value="1" id="h" name="n" runat="server" />
<script>
$("a").on("tap", function (event) {
var a = event.target.id;
$("#h").val(a);
});
</script>
and the server side part:
<%
string param = h.Value;
Response.Write(param);
%>
The input field has an initial value=1. A JQuery event changes the value attribute to, let's say, 5. When I try to access the value of input from server side (h.Value), the value is again, 1.
What am I doing wrong?
Thank you.
我相信你需要使用ASP.NET TextBox
控件而不是普通的html input
。
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.