How do I get OnButtonClick from a RadToolBar in an ascx to fire the event?

1 Answer 95 Views
Grid ToolBar UI for ASP.NET AJAX in ASP.NET MVC
caesar
Top achievements
Rank 1
caesar asked on 29 Apr 2021, 05:16 PM

I have two pages:

a.aspx
b.ascx

The goal is to get the RadToolBarButtons on b.ascx to fire the OnButtonClick() event as defined in the RadToolBar .

a.aspx is the host page for b.ascx and has this placeholder for different RadGrids:

<div id="divMiniGrid" runat="server" visible='<%# ActiveViewID != "viewFees" %>' class="rightPane">
         <sf:PaymentDetailsGrid ID="ctlMiniGrid" runat="server" class="rightPane" Visible="false" IsCondensed="true" />
</div>


b.ascx has the actual RadGrid that is loaded in a.aspx. The RadGrid has an ItemTemplated RadToolbar:

 <telerik:RadGrid ...>
    <MasterTableView ...>
        <CommandItemTemplate>
            <telerik:RadToolBar ... OnButtonClick="PaymentDetailsToolbar_ButtonClick" EnableViewState="true"  onClientButtonClicking="ClientButtonClicking" ...>
                <Items>
                    <telerik:RadToolBarButton runat="server" Text="Edit" ImageUrl="../images/icons/refresh.svg" CommandName="Edit" Enabled="False" />



The PaymentDetailsToolbar_ButtonClick() event lives on b.ascx, but it is never fired when the RadToolBarButton is clicked. Here's the signature:

protected void PaymentDetailsToolbar_ButtonClick(object sender, Telerik.Web.UI.RadToolBarEventArgs e){...}

The only event that is fired is a.aspx Page_Load() event when the RadToolBarButton is clicked. What's going on?

1 Answer, 1 is accepted

Sort by
0
Attila Antal
Telerik team
answered on 04 May 2021, 09:53 AM

Hi Caesar,

Regardless of where the Controls are located from a number of pages. It can be on A, B, C or D if the A is a MasterPage/ContentPage that has the Script (e.g. Script.js) registered, and the Control in B, C or D (UserControls) is calling the function which is located inside the Scripts.js file.

For instance, you can place the PaymentDetailsToolbar_ButtonClick function in the Scripts.js file, and this to be registered in the a.aspx Page. Have the Toolbar control inside the b.ascx UserControl that will call the javaScript method.

I hope this will prove helpful. 

Regards,
Attila Antal
Progress Telerik

Тhe web is about to get a bit better! 

The Progress Hack-For-Good Challenge has started. Learn how to enter and make the web a worthier place: https://progress-worthyweb.devpost.com.

Tags
Grid ToolBar UI for ASP.NET AJAX in ASP.NET MVC
Asked by
caesar
Top achievements
Rank 1
Answers by
Attila Antal
Telerik team
Share this question
or