Calling ButtonClick event from Javascript

3 posts, 0 answers
  1. Bill Togkas
    Bill Togkas avatar
    18 posts
    Member since:
    Mar 2010

    Posted 26 Jan 2012 Link to this post

    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. jumpstart
    jumpstart avatar
    479 posts
    Member since:
    Nov 2011

    Posted 30 Jan 2012 Link to this post

    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!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Bill Togkas
    Bill Togkas avatar
    18 posts
    Member since:
    Mar 2010

    Posted 31 Jan 2012 Link to this post

    Tnx! Nice 1 :D
Back to Top