Posted on: 3/24/2012 8:08:27 AM | Views : 502

I'm working with a web application that needs to get access to an ASP.NET web control (a button) in javascript. The problen is that since the control is run on the server, javascript can't access it in the standard way (i.e. document.getElementById(controlId);).
I've actually solved this problem before in a different application, but my solution there doesn't seem to work here for some reason.
I have this in an aspx file:

 
<script...> ... function myfun() { var b = document.getElementById("<%=SaveButton.ClientID%>"); alert(b); } </script> ... <asp:Button ID="SaveButton" Text="save" OnClientClick="myfun()" ClientIDMode="Static" runat="server" UseSubmitBehavior="False" />  
I have a designer class in which the button is declared (and therefore exists in the server-side codebehind):
protected global::System.Web.UI.WebControls. ...

Go to the complete details ...