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

How to call a Javascript function from RadGrid Update Button

2 Answers 437 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jagat
Top achievements
Rank 1
Jagat asked on 21 Jul 2011, 07:42 PM
Hello,

    I have a Radgrid in my web application . When I edit a row in the Radgrid, I want to call a javascript function (which will get the geocodes ) from the update button. I know we can add the attributes if the button is on the form. But that is not the case now.

I am accessing that update button in the itemDatabound event like this

  Dim editItem As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
   Dim updateButton As ImageButton = DirectCast(editItem.FindControl("UpdateButton"), ImageButton)

Appreciate the Help
Thanks

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 22 Jul 2011, 05:55 AM
Hello Jagat,

You can call a Javascript function from UpdateButton as shown below.
VB:
Protected Sub RadGrid1_ItemDataBound(sender As Object, e As GridItemEventArgs)
    If TypeOf e.Item Is GridDataItem Then
        Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim imgBtn As ImageButton = DirectCast(item.FindControl("UpdateButton"), ImageButton)
        imgBtn.Attributes.Add("onclick", "handler();")
    End If
End Sub

Javascript:
<script type="text/javascript">
    function "handler()
    {
     var RadGrid1 = $find("<%= RadGrid1.ClientID %>");
      . . . .
    }
</script>

Thanks,
Princy.
0
Jagat
Top achievements
Rank 1
answered on 22 Jul 2011, 03:57 PM
Thank you...
Tags
Grid
Asked by
Jagat
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Jagat
Top achievements
Rank 1
Share this question
or