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

[Solved] How to Acess control in Edit Form User Control RadGrid ??

1 Answer 254 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thannapan Boonpannaruk
Top achievements
Rank 1
Thannapan Boonpannaruk asked on 12 Jan 2010, 05:17 AM
I have a problem to access textbox in edit form user control RadGrid in case use 'Javascript'.
 
Error on javascript show me that 'Reference object is null' or 'getElementID(...)'

How do I fix it out ?
Anyone help me,please.

Thank you,
NaPann

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 12 Jan 2010, 08:05 AM
Hello NaPann,

You can access the textbox client id and save it in a hidden field from code behind. Then on the client you can access the textbox id from the hidden field. Here's an example:
aspx:
<asp:HiddenField ID="HiddenField1" runat="server" /> 

c#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
        { 
            GridEditableItem editItem = (GridEditableItem)e.Item; 
            UserControl cntrl = (UserControl)editItem.FindControl(GridEditFormItem.EditFormUserControlID); 
            HiddenField1.Value = ((TextBox)cntrl.FindControl("TextBox1")).ClientID; 
        } 
    } 

js:
function customFunction() 
    {       
       var hiddenfield = document.getElementById("HiddenField1");           
       var textbx = document.getElementById(hiddenfield.value); 
       alert(textbx.value); 
    } 

Also another option would be to store the client id of the textbox editor in window object attribute (global scope variable) and then trace the textbox on the client calling the document.getElementById(id) javascript method as illustrated in the following code library submission:
Retrieving grid editor value client side

Thanks
Princy.
Tags
Grid
Asked by
Thannapan Boonpannaruk
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or