Click here to Skip to main content
15,885,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How to access javascript function parameter value from code behind in asp.net
Posted
Comments
Not clear. Can you elaborate more?
Member 10848796 21-Jul-14 12:11pm    
I have a javascript function with parameter(passing textbox id in parameter) to show popup(showing WebDataGrid in popup) on mouseover of all Textboxes. I want to access "ID" of textbox where the cursor is focused so that WebDataGrid can be refreshed everytime.

1 solution

Set the javascript parameter to a hidden field.
Access the hidden field from your code behind.

JavaScript:
JavaScript
<script>
function SendValueToCodeBehind(myValue){
     document.getElementById('hdnJavaScriptValue').value = myValue;
}
</script>


ASPX:
XML
<asp:hiddenfield id="hdnJavaScriptValue" runat="server" xmlns:asp="#unknown"></asp:hiddenfield>


Code Behind:
VB
Dim oJavaScriptValue as Object = hdnJavaScriptValue.Value
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900