I have a textbox;
<input runat="server" type="hidden" value="0" id="input1" name="input1_name">
I have a div;
<div id="div1"> some content </div>
I have a seperate .js file where I have a function which is loaded at the Page Load. In that function I have:
$("#div1").click(function(e){
definition;
});
I want to pass the client id of the input control mentioned above to the click handler in the above scenario.I have not been able to use the property ClientID on the above mentioned javascript file. Rest all is working fine.
Please advise how do I pass parameters to the click handler of a control on aspx page to the javascript file (in a way getting ClientID there).
This is on .NET.
Please let me know in case I need to post any more details here, if anything look ambiguous.
Depending on which version of ASP.NET you use you have a couple of options.
Before ASP.NET 4.0 you can do something like this:
In ASP.NET 4.0 a new feature was introduced:
ClientIDMode:will output:
If you use the static
ClientIDModeyou can use the Id in your JavaScript without any problems.Here is a nice blog that explains the different options: ASP.NET 4.0 ClientID Overview