I am attempting to pass different values to a javascript function depending on which button is clicked.
I have two hiddenfields on the page and I want the value of the first field hidA
to be used when btnA
is clicked and the second field hidB
value to be used when btnB
is clicked.
The value will then be read by javascipt.
EXAMPLE
onclick="test(22);"
However I am unable to read .Net control values without breaking the syntax.
ASPX
<input id="btnA" type="button" value="A" onclick="test($('#<%= hidA.ClientID%>').val());"/>
<input id="btnB" type="button" value="B" onclick="test($('#<%= hidB.ClientID%>').val());"/>
Jquery
function test(e){
$('#label').text(e);
}
QUESTION
How can ASP.NET control values be passed to a javascript function?