Grid - part of name of FormTemplate control

2 posts, 0 answers
  1. Krzysztof
    Krzysztof avatar
    29 posts
    Member since:
    Aug 2008

    Posted 05 Oct 2008 Link to this post

    Hi

    I have a Grid width PopUp style editing like :
    ....
    <EditFormSettings EditFormType="Template" >      
                               <FormTemplate>
                               <asp:TextBox id="TextBox7"  runat="server"
                               Text='<%# DataBinder.Eval( Container, "DataItem.FieldName" ) %>'>
                            </asp:TextBox>
                            <br />
                               <asp:Button ID="UpdateButton" OnClientClick="GetNewData(this, event);" Text="Update"
                                     runat="server" />
                               </FormTemplate>
                                                   
                           </EditFormSettings>
    ....

    ... and I have JavaScript finction like :

    function GetNewData(sender, e)
    {
      var grid = $get("Grid1");
      var inputs = grid.getElementsByTagName("input");
      for (var i = 0; i < inputs.length; i++)
      {  
        var input = inputs[i];
        if (input.id == "Grid1_ctl00_ctl05_" + "TextBox7")
        {
          alert(input.value);
        }  
      }
     }

    Every thing work well but I have't got grid id directly from JavaScript code. I need this becoures I have to find control named "Grid1_ctl00_ctl05_TextBox7".
    My question is : How can I get grid unique id like "Grid1_ctl00_ctl05_" ??? 

    Regards
    Krzysztpf
  2. Yavor
    Admin
    Yavor avatar
    11 posts

    Posted 08 Oct 2008 Link to this post

    Hello Krzysztof,

    One possible approach in this case is to use the code-behind and get the id there. This id can be assigned to a hidden input on the page, which can later be accessed to get the id of the element you need.
    I hope this is a suitable approach for you.

    Best wishes,
    Yavor
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top