Getting controls id in the javascript RRS feed

  • Question

  • User-2146620081 posted


    After spending long time on getting controls id in the javascript, I am sharing my query. I have used user controls in my page. In the user controls, I am using Infragistics spellchecker for the text boxes and I have written cleintscript for the spellcheck to call the infragistics spellcheck method. Here I have issue on getting controls id from the usercontrols. In my project,some textbox ids are same in the user controls.

    For ex: Itemdisplay.ascx -   <asp:TextBox id="txtDisplay" runat="server" /> &  ItemCreate.ascx - <asp:TextBox id="txtDisplay" runat="server" />


    <script language="javascript" type="text/javascript">

    function checkspelling(txt){

    var spellchk= ig_getWebControlById("webspellchk");


    return false;


    Itemdisplay.ascx -   <asp:TextBox id="txtDisplay" runat="server" /><asp:ImageButton id="imgbtn" runat="server" Onclientclick="return checkspelling('txtDisplay');"/>

    ItemCreate.ascx<asp:TextBox id="txtDisplay" runat="server" /><asp:ImageButton id="imgbtn1" runat="server" Onclientclick="return checkspelling('txtDisplay');"/>

    I am not getting id of text box in the javascript. I used ClientID of the textbox  also. Let me know how to pass the id of the textbox to Javascript method?





    Monday, February 6, 2012 3:21 AM

All replies

  • User-366017857 posted

    Use this one

    To pass the control ID to javascipt function

    Onclientclick="return checkspelling(this);"

    To get control

    function checkspelling(txt){

    var spellchk= document.getElementById(txt);


    var spellchk= document.getElementById('<% "txt"+".ClientID %>"');


    return false;

    var Element =

    Monday, February 6, 2012 4:11 AM
  • User-2146620081 posted


    Thanks for your reply. I have written ClientClick method for the Imagebutton then how can i pass 'this' object?

    Tuesday, February 7, 2012 12:25 AM