Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
539
how i can get the clientid of the web image button in javascript .
posted

Hai

 

Iam Using a webimagebutton in a webform which is inherited from a masterpage.The problem iam faicing is that, iam not able to acess the webimagebutton in javascript.

i think this is because the id of the control will change when it is used inside a mastre page and i have to refer the webimagbutton using its clientid.

 

Can any body help me in, how i can get the clientid of the web image button in javascript .

 

Regards

Rajesh Kamalakshan 

  • 446
    Offline posted

    <script>

    var buttonClientId = '<%=igButton.ClientID;%>';

    </script>

  • 28407
    posted

    HI ,

    Veiw the source code of the page, this will help you determine the clientID.

    For a webimagebutton in a master page - refer to it as

    ctl00_WebImageButton1

     

    For an webimagebutton in a contentplaceholder - refer to it as

    ctl00_ContentPlaceHolder1_WebImageButton1

  • 625
    posted

    ASP controls are rendered using different ID's from the one declared.

    If, for example, you have the button called 'btnTest' and that button is one a web page which has a master page, then the button is actually contained in a ContentPanel on the web page.

    To refer to it you would have to use code like :-

    var myButton = document.getElementbyId("ctl00_ContentPlaceHolder1_btnTest");

    If the button is further nested in other controls in the web page, then it can get more complex.