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

Is there a demo that shows how to access and manipulate controls within a RadGrid form template popup on the client side?

2 Answers 95 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boris
Top achievements
Rank 1
Boris asked on 07 Nov 2012, 06:44 PM
I'm sorry if this is partially a duplicate of a previous entry but I need a fast answer.

I need to be able to be able to enable and disable textboxes and other controls within a RadGrid's popup using a Javascript call from a check box on that same popup.

Every entry I've found seems to contradict the previous and nothing works.

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 08 Nov 2012, 06:24 AM
Hi Boris,

I guess you want to disable a TextBox in edit form in CheckBox click on client side. Please take a look into the following code snippet.

C#:
protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if ((e.Item is GridEditableItem) && (e.Item.IsInEditMode))
    {
        {
            GridEditableItem editForm = (GridEditableItem)e.Item;
            TextBox txt = (TextBox)editForm.FindControl("TextBox1");
            CheckBox chk = (CheckBox)editForm.FindControl("CheckBox1");               
            chk.Attributes.Add("onclick", "oncheckedChaned(this,'" + txt.ClientID + "'); ")
        }
    }
}

Javascript:
<script type="text/javascript">
    function oncheckedChaned(chk, txtid)
    {
       
        var TextBox = document.getElementById(txtid);
        TextBox.disabled = true;
         
    }
</script>

Thanks,
Shinu.
0
Boris
Top achievements
Rank 1
answered on 08 Nov 2012, 01:57 PM
Thank you for your response.  That worked. 

I should point out that Eyup gave me a somewhat different response that also worked. 
http://www.telerik.com/community/forums/aspnet-ajax/input/unable-to-find-a-usable-method-for-enabling-disabling-a-textbox-in-a-formtemplate.aspx

(I've been away from JavaScript for some time.  I confess that I don't find either of your answers intuitive.  But thanks!  )

Tags
Grid
Asked by
Boris
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Boris
Top achievements
Rank 1
Share this question
or