javascript - asp.net control id's in separate JS file -
I have a custom control with a set of buttons and input. I also have a JS file, where my code is easy Goes to debugging.
How do I obtain the client ID of the controls in the JS file?
At this time my action is that there is a script block at the top of the control and put all JS there. I want to do something different.
Many thanks
As the global variable in your Controller ID page
In your custom control, page or user control:
string script = "& lt; script>; var myButtonID = '" + myButton.ClientID + "'; & Lt; / scripts & gt; "; If (! Page classic script. ILLX script block prohibited ("Miglobelvaryables")) {page. Classic script Registry ClientBlock (This. Gettype, "MyGlobal Wainbles", script); } and in your external JS file:
var myButton = document.getElementById (myButtonID); // var myButton = $ ('#' + myButtonID); Here's how to present your control ID in Aspx / ascx files: & lt; Script language = "javascript" & gt; Var myButtonID = '& lt;% = muButton.ClientID% & gt;'; & Lt; / Script & gt;
Comments
Post a Comment