ASP.NET read value of javascript variable

  • Thread starter Thread starter Elliot
  • Start date Start date
E

Elliot

My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.
 
My C# page contains a java script that create a variable named txt.
How can I get the value of txt when pressing a ASP.NET button?
Any idea would be appreciated.

something like this:
<input type="hidden" runat="server" id="hiddenVariableValue" />
<asp:Button ..... onClientClick="return copy_variable();" />

where
<script>
var hidden_field_id = "<%=hiddenVariableValue.ClientID%>";
function copy_variable()
{
document.getElementById(hidden_field_id ).value =
your_txt_value_here;
return true;
}
</script>



more at http://www.siccolo.com/articles.asp
 
Back
Top