This is a migrated thread and some comments may be shown as answers.

Grid - part of name of FormTemplate control

1 Answer 16 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 05 Oct 2008, 01:53 PM
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

1 Answer, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 08 Oct 2008, 06:27 AM
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.
Tags
Grid
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Share this question
or