Im trying to request javascript variable and use it in code behind, but it always has the value of "" Im not sure whats wrong, it should work based on examples I have looked at. Any help - or different methods to request Js variable to .net webforms (c#) would be very much appreciated, thanks.
<script type="text/javascript">
function SetPostbackValues() {
var myvalue = "abcdefg";
document.getElementById("hiddenControl1").value = myvalue;
}
</script>
<div class="jumbotron">
<input id="hiddenControl1" type="hidden" runat="server" />
<asp:Button ID="Button1" runat="server" OnClientClick="SetPostbackValues()" OnClick="Button1_Click" Text="Button" />
</div>
....
protected void Button1_Click(object sender, EventArgs e)
{
var hiddenValue = hiddenControl1.Value;
//use value
}