1

How can I add a javascript method to the update button of GridEditCommandColumn in Telerik RadGrid?

I need to fire a js method on the update button of EditCommandColumn. I was able to add clientside event on the edit button but while clicking edit button it turns out to update and cancel. I want to add a js method to this update button.

Please find the column in aspx page below

Thank you very much in advance.

2 Answers 2

1

Thanks Sikandar. I followed your answer to get the result I wanted.

if (e.Item is GridDataItem && e.Item.Edit)
        {
            GridDataItem item = (GridDataItem)e.Item;
            Button btn = (Button)item.FindControl("UpdateButton");
            btn.Attributes.Add("OnClick", "return confirmBox();");
        }
Sign up to request clarification or add additional context in comments.

Comments

0

Try following code

<telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditColumn">
                </telerik:GridEditCommandColumn>


Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = TryCast(e.Item, GridDataItem)

        DirectCast(item("EditColumn").Controls(0), ImageButton).Attributes.Add("onclick", "alert('test')")
    End If
End Sub

1 Comment

I have tried this one. The alert box appears on the edit button click. I want to show it in the update button click. (Here the edit button when clicked splits up into update and cancel buttons.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.