how to find a GridView label ClientID in js file

Discussion in 'ASP .Net' started by Deere, Oct 17, 2008.

  1. Deere

    Deere Guest

    I have an asp:label inside a GridView that I'm trying to put a value
    into from a JS file.

    I can successfully do it by looking at page source and then manually
    constructing the following

    document.getElementById("GridView1_ctl02_qty").innerText = " ( " +
    mySplitResult[0] + " )"

    But I can't get the server ID of the label by requesting it in the js
    file.. I've tried several variations.....
    document.getElementById('<%=GridView1.qty.ClientID%>')
    document.getElementById('<%=GridView1.FindControl("qty").ClientID%>');
    document.getElementById('<%=qty.ClientID%>')
    document.getElementById('<%=GridView1$qty.ClientID%>')

    I can though, put a value into a < input type ="text" id="qtyy">
    inside Gridview by using.
    document.getElementById("qtyy").value = " ( " + mySplitResult[0] +
    " )"

    can someone point out my error.. or where I need to look



    thanks
     
    Deere, Oct 17, 2008
    #1
    1. Advertising

  2. Deere

    J. Renou Guest

    I have your solution :

    var controlId = '<%= ((TextBox)GridView1.FindControl("qty")).ClientID %>';
    document.getElementById(controlId);

    enjoy

    "Deere" wrote:

    > I have an asp:label inside a GridView that I'm trying to put a value
    > into from a JS file.
    >
    > I can successfully do it by looking at page source and then manually
    > constructing the following
    >
    > document.getElementById("GridView1_ctl02_qty").innerText = " ( " +
    > mySplitResult[0] + " )"
    >
    > But I can't get the server ID of the label by requesting it in the js
    > file.. I've tried several variations.....
    > document.getElementById('<%=GridView1.qty.ClientID%>')
    > document.getElementById('<%=GridView1.FindControl("qty").ClientID%>');
    > document.getElementById('<%=qty.ClientID%>')
    > document.getElementById('<%=GridView1$qty.ClientID%>')
    >
    > I can though, put a value into a < input type ="text" id="qtyy">
    > inside Gridview by using.
    > document.getElementById("qtyy").value = " ( " + mySplitResult[0] +
    > " )"
    >
    > can someone point out my error.. or where I need to look
    >
    >
    >
    > thanks
    >
    >
    >
     
    J. Renou, Nov 14, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maras
    Replies:
    1
    Views:
    3,146
    Cowboy \(Gregory A. Beamer\)
    Oct 15, 2003
  2. Neo Geshel

    Trying to find ClientID of web form

    Neo Geshel, Jun 18, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    384
    Brock Allen
    Jun 18, 2005
  3. Neo Geshel

    Trying to find ClientID of web form

    Neo Geshel, Jun 18, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    4,428
    Neo Geshel
    Jun 18, 2005
  4. Deere
    Replies:
    2
    Views:
    119
    Deere
    Oct 28, 2008
  5. Knut Krueger
    Replies:
    8
    Views:
    292
    Knut Krueger
    Aug 20, 2013
Loading...

Share This Page