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

[Solved] How to Inject Javascript Code on RadGrid_EditCommand

2 Answers 174 Views
Grid
This is a migrated thread and some comments may be shown as answers.
aung maw
Top achievements
Rank 1
aung maw asked on 06 Apr 2009, 12:29 AM
Hi All, I would like to inject Javacript code to manipulate HTML inside user control on server side RadGrid_EditCommand.  Based on category value of a row, I would need to change editable fields on the fly.  So if category is 1 then only show A, B field.  If it is 2 then show B, C on the edit form.



Many Thanks,


<EditFormSettings UserControlName="N.ascx" EditFormType="WebUserControl">                                     
</EditFormSettings>


    protected void RadGrid_EditCommand(object source, GridCommandEventArgs e)
    {
        // inject javascript here to manipulate HTML in usercontrol????
    }

2 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 08 Apr 2009, 03:41 PM
Hello Aung,

To achieve your goal you need to find the user control and inject in it the required JavaScript. Hence I will suggest you just find the proper controls in this user control and hide or show them when EditCommand event is raised.

Here is a code snippet illustrating how to achieve this:
           UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID); 

For further information please review this online help article. Nevertheless you can use this implementation in the EditCommand event handler too.

Best regards,
Georgi Krustev
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
aung maw
Top achievements
Rank 1
answered on 10 Apr 2009, 01:44 PM
Many Thanks Georgi ,
Tags
Grid
Asked by
aung maw
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
aung maw
Top achievements
Rank 1
Share this question
or