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

get textbox clientID inside EditFormSettings

3 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
padmaja
Top achievements
Rank 1
padmaja asked on 20 May 2009, 09:19 AM
Hi All,

In my code am using Telerik Grid . Inside telerik Grid am using EditFormSettings tab to update Grid details.
I don't know how to get a ClientID of my textbox inside the user control. I want to apply the javascript to that textbox.
I need clientID for that textbox.

Could you please help me to how can i get Client ID inside the User Control in Telerik Grid

Here am Placing my sample code.
<radG:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowFilteringByColumn="False" 
                AllowMultiRowSelection="false" AllowPaging="True" AllowSorting="True" BackColor="Transparent" 
                DataSourceID="GridDataSource" EnableAJAX="false" EnableAJAXLoadingTemplate="false" 
                EnableViewState="true" GridLines="None" LoadingTemplateTransparency="50" ShowGroupPanel="True" 
                ShowStatusBar="False" AutoGenerateColumns="true" OnUpdateCommand="RadGrid1_UpdateCommand" 
                SkinID="myGrid" OnColumnCreated="ColumnCheck" OnPreRender="ReduceFilter" Width="100%" 
                OnItemDataBound="ColDatabind">  
                <MasterTableView DataSourceID="GridDataSource" GroupLoadMode="Client">  
                    <Columns> 
                        <radG:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="~/Images/edit.gif" 
                            UniqueName="EditCommandColumn1" Resizable="False" Reorderable="False">  
                            <HeaderStyle Width="15px" /> 
                        </radG:GridEditCommandColumn> 
                        <radG:GridTemplateColumn UniqueName="AssignUser" AllowFiltering="False" Reorderable="False" 
                            Groupable="False" Resizable="False" Visible="false">  
                            <HeaderStyle Width="20px" /> 
                            <HeaderTemplate /> 
                            <ItemTemplate> 
                                <asp:ImageButton runat="Server" ID="ibtnAssignMsg" ImageUrl="~/images/Asgn.gif" CommandName="AssignMsgToUser" 
                                    ToolTip="Assign SMS to User" Visible="false" /> 
                            </ItemTemplate> 
                        </radG:GridTemplateColumn> 
                        <radG:GridTemplateColumn UniqueName="myselect" AllowFiltering="False" Reorderable="False" 
                            Groupable="False" Resizable="False">  
                            <HeaderStyle Width="20px" /> 
                            <HeaderTemplate> 
                                <asp:CheckBox ID="selectall" runat="Server" OnLoad="SelectAll" /> 
                            </HeaderTemplate> 
                            <ItemTemplate> 
                                <asp:CheckBox runat="Server" ID="myselect" OnLoad="ClearSAll" /> 
                            </ItemTemplate> 
                        </radG:GridTemplateColumn> 
                    </Columns> 
                    <EditFormSettings UserControlName="~/editform.ascx" EditFormType="WebUserControl" > 
                        <EditColumn UniqueName="EditCommandColumn">  
                        </EditColumn>                          
                    </EditFormSettings> 
                    <NoRecordsTemplate> 
                        <table width="100%">  
                            <tr> 
                                <td align="center">  
                                    There are no items to display. Please check your selection criteria and retry.  
                                </td> 
                            </tr> 
                        </table> 
                    </NoRecordsTemplate> 
                    <FooterStyle Height="0px" /> 
                    <ExpandCollapseColumn Visible="False">  
                        <HeaderStyle /> 
                    </ExpandCollapseColumn> 
                    <RowIndicatorColumn Visible="False">  
                        <HeaderStyle /> 
                    </RowIndicatorColumn> 
                </MasterTableView>                 
                <ClientSettings AllowGroupExpandCollapse="True" AllowDragToGroup="True" AllowColumnsReorder="True" 
                    ColumnsReorderMethod="Reorder" ApplyStylesOnClient="True">  
                    <Selecting AllowRowSelect="True" /> 
                    <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="True" />                     
                </ClientSettings> 
            </radG:RadGrid> 

3 Answers, 1 is accepted

Sort by
0
Pavlina
Telerik team
answered on 20 May 2009, 09:56 AM
Hello Padmaja,

You can not get the ClientID of your textbox inside the user control, because the user control is an INaming Container - this means that it changes the ClientIDs of the controls which are placed inside it. This is general ASP.NET knowledge and you can reproduce the issue by using a standard control.

What I can suggest is to try passing the ClientID directly from the server, e.g.:
strScript += "top.$get('" + btnRebindGrid.ClientID + "').click();" 
 
Another option is to find the actual client ID of the button by using the IEDevToolBar or Firebug tools and hard-code it.


Best wishes,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Princy
Top achievements
Rank 1
answered on 20 May 2009, 09:59 AM
Hello Padmaja,

You can try out the following code to get the client id of the textbox in the usercontrol on client:
c#:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditFormItem && e.Item.IsInEditMode) 
        { 
            GridEditFormItem editFormItem = (GridEditFormItem)e.Item; 
            UserControl user = editFormItem.FindControl(GridEditFormItem.EditFormUserControlID) as UserControl; 
            TextBox txt =(TextBox)user.FindControl("TextBoxID"); 
            txt.Attributes.Add("onChange""return textChange( " + txt.ClientID + "); "); 
 
        } 
    } 

js:
<script type="text/javascript"
 
 function textChange(clientId) 
  { 
    alert(clientId); 
  } 
 
</script> 

Thanks
Princy.
0
padmaja
Top achievements
Rank 1
answered on 21 May 2009, 03:20 AM
Hi Princy,

Thank you very much for your support.

This code what you said was correct and I can assign onclick event int RadGrid1_ItemCommand.
Actually my problem is :
I need to get the client ID in PageLoad not in RadGrid1_ItemCommand method.
The same what you wrote if i can get in Page_Load my problem will be solve.

Could you please help me how can i get in page_load.

Tags
Grid
Asked by
padmaja
Top achievements
Rank 1
Answers by
Pavlina
Telerik team
Princy
Top achievements
Rank 1
padmaja
Top achievements
Rank 1
Share this question
or