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

Calling ButtonClick event from Javascript

2 Answers 126 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Bill Togkas
Top achievements
Rank 2
Bill Togkas asked on 27 Jan 2012, 01:59 AM
Hi guys

I want to call buttonClick event from javascript

 <telerik:RadToolBar ID="_rtooMenu" runat="server" Width="100%" dir="rtl">
            <Items>
                <telerik:RadToolBarButton runat="server" Text="Save" Value="Save" Owner="_rtooMenu" PostBack="true">
                </telerik:RadToolBarButton>
            </Items>
</telerik:RadToolBar>

<script type="text/javascript">
         function FunctionFoundByJavascriptThroughLayersAndLayersOfControls() {
__dopostback ????
         }
    </script>

 Protected Sub _rtooMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles _rtooMenu.ButtonClick
'I want FunctionFoundByJavascriptThroughLayersAndLayersOfControls to get here

end sub

2 Answers, 1 is accepted

Sort by
0
Richard
Top achievements
Rank 1
answered on 30 Jan 2012, 05:06 PM
Bill:

Try this approach. It worked for me:

Toolbar definition:
<telerik:RadToolBar ID="_rtooMenu" runat="server" Width="100%" >
    <items>
        <telerik:RadToolBarButton runat="server" Text="Save" Value="Save" PostBack="true">
        </telerik:RadToolBarButton>
    </items>
</telerik:RadToolBar>

Javascript:
<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
        function FunctionFoundByJavascriptThroughLayersAndLayersOfControls() {
            var toolBar = $find("<%=_rtooMenu.ClientID %>");
            var button = toolBar.findItemByText("Save");
            button.click();
        }
    </script>
</telerik:RadCodeBlock>

Default.aspx.vb:
Imports Telerik.Web.UI
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub _rtooMenu_ButtonClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles RadToolBar1.ButtonClick
        MsgBox("Event fired!")
    End Sub
End Class

Hope this helps!
0
Bill Togkas
Top achievements
Rank 2
answered on 31 Jan 2012, 07:39 PM
Tnx! Nice 1 :D
Tags
ToolBar
Asked by
Bill Togkas
Top achievements
Rank 2
Answers by
Richard
Top achievements
Rank 1
Bill Togkas
Top achievements
Rank 2
Share this question
or