Passing values from javascript to code in ASP.NET
1 answer
Using html controls
First, you use a hidden input control:
<input type="hidden" value="" id="SendA" name="SendA" />
Second, you add to this element the value you want to send by code using javascript like:
document.getElementById("SendA").value = "1";
And then in the response post you will receive this value as:
Request.Form["SendA"]
Using asp.net controls
Likewise, if you are using asp.net control you can:
<asp:HiddenField runat="server" ID="SendA" Value="" />
<script>
document.getElementById("<%=SendA.ClientID%>").value = "1";
</script>
and get it by code with SendA.Value;
And of course you can use ajax calls to send over code for values or a simple call url with url parameters that don't return content.
+6
source to share