The trick to passing data from Javascript and Asp.Net is to use hidden inputs in the html. The hidden inputs should have the runat="server" attribute. For example:
Then in the Javascript, whatever value you are trying to pull from Asp.Net,
set the hidden field using:
And in the Asp.net form, you can just access the hiddenfield by using its id.
Thats all there is to it. You might need to check the syntax of it first as this is just all from my head.
<input type="hidden" runat="server" id="hiddenfield" value="" />
Then in the Javascript, whatever value you are trying to pull from Asp.Net,
set the hidden field using:
document.getElementById("hiddenfield").value = "whatever value you want to set"
And in the Asp.net form, you can just access the hiddenfield by using its id.
string x = hiddenfield.value.text
Thats all there is to it. You might need to check the syntax of it first as this is just all from my head.
Comments