To get tool bar button from the sender in OnRequestStart - Ajax Manager

6 posts, 0 answers
  1. Rose Garza
    Rose Garza avatar
    45 posts
    Member since:
    Nov 2006

    Posted 30 Jul 2008 Link to this post

    Hi,

    I have a Splitter which has a tool bar with in it. Tool bar consists of 4 buttons. I have a AjaxManager which is used when any action on Splitter is performed. For example if i click on tool bar button which is with in Splitter, the OnRequestStart of the Ajax manager is called.
    The issue is that how to get the tool bar button in the client side in OnRequestStart event. Right now, when i click on a button, from the eventArgs.EventTarget property i get the tool bar id, but not the specific tool bar button. Please provide a solution to get the specific tool bar button whcih is clicked by the user in OnRequestStart event.


  2. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 31 Jul 2008 Link to this post

    Hello Rose Garza,

    Here is one solution:

    Declare a global javascript variable which will store the currently clicked toolbar item - this will happen in OnClientItemClicked event for example. Then in the OnRequestStart event handler you can access the global javascript variable.
    Here is a sample code:

    <script type="text/javascript"
    //global variable holding the last clicked item 
    var clickedItem; 
     
    function OnRequestStartHandler(sender, eventArgs) 
        if (clickedItem) 
        { 
            alert(clickedItem.get_text()); 
        }    
     
    function OnClientButtonClickedHandler(sender, eventArgs) 
        //initialize the clickedItem var     
        clickedItem = eventArgs.get_item(); 
    </script>  

    I hope this helps.

    Regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Rose Garza
    Rose Garza avatar
    45 posts
    Member since:
    Nov 2006

    Posted 31 Jul 2008 Link to this post

    Thanks Veskoni.
    I'm already following this solution, the issue is that my web page has to work in both IE and firefox. This solution works fine in IE, but in Firefox the OnRequestStart is called first before the OnClientItemClicked, hence the global variable is 'undefined'. That is why i asked the question that whether from the sender or eventArgs argument of the OnRequestStart event, can i get the tool bar button clicked? Please suggest any alternate solutions too if you have any.
  5. Veselin Vasilev
    Admin
    Veselin Vasilev avatar
    2992 posts

    Posted 01 Aug 2008 Link to this post

    Hello Rose Garza,

    Are you using the latest version?

    At my side the OnClientButtonClicked is called before OnRequestStart under IE 7 and Firefox3.

    You can try subscribing to OnClientButtonClicking instead, and let me know the results.

    Regards,
    Veskoni
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Rose Garza
    Rose Garza avatar
    45 posts
    Member since:
    Nov 2006

    Posted 05 Aug 2008 Link to this post

    Hi,

    OnClientButtonClicked and OnClientButtonClicking did not work for me. I have the following code, please check the same in IE and firefox. The client side click event of the toolbar button should be called first and then OnRequestStart of the Ajax, but it happens reverse in case of Firefox.

    The code is,

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 
    <%@ Register Assembly="RadToolbar.Net2" Namespace="Telerik.WebControls" TagPrefix="radTlb" %> 
    <%@ Register Assembly="RadAjax.Net2" Namespace="Telerik.WebControls" TagPrefix="radA" %> 
    <%@ Register Assembly="RadSplitter.Net2" Namespace="Telerik.WebControls" TagPrefix="radspl" %> 
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     
    <html xmlns="http://www.w3.org/1999/xhtml" > 
    <head runat="server">  
        <title>Untitled Page</title> 
        <script language="javascript" type="text/javascript">  
            function click_more()  
            {  
                alert('click_more');  
                return false;  
            }  
              
            function Defaul_click()  
            {  
                alert('Default_click');  
                return false;  
            }  
              
            function RequestStart(sender, eventArgs)  
            {  
                alert(eventArgs.EventTarget);  
            }  
              
        </script> 
    </head> 
    <body> 
        <form id="form1" runat="server">  
        <div> 
        <radspl:RadSplitter ID="radSplitter" runat="server" Skin="Outlook" Width="100%" Visible="true" 
                    ResizeWithParentPane="true" ResizeWithBrowserWindow="true" ResizeMode="EndPane">  
        <radspl:RadPane ID="radtvwPane" runat="server" Width="20%" Scrolling="Both" Height="100%" 
                        EnableViewState="true">  
                                        <radTlb:RadToolbar ID="tbrButtons" runat="server" UseFadeEffect="True" Skin="Mac" 
                                        SkinsDir="~/RadControls/Toolbar/Skins/" AutoPostBack="true">  
                                        <Items> 
                                            <radTlb:RadToolbarButton ID="rbtnMore" DisplayType="TextImage" CommandName="More" 
                                                ButtonImage="row_add.png" Hidden="False" runat="server" Style="font-weight: normal;  
                                                font-family: Tahoma" ButtonText="Add" ToolTip="Add row" onClick="return Defaul_click();"/>  
                                                </Items> 
                                                </radTlb:RadToolbar> 
            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="if(!Defaul_click()){return false;}" /> 
            </radspl:RadPane>     
            </radspl:RadSplitter> 
              
                <radA:RadAjaxManager ID="ajaxPnlResults" runat="server">  
                <AjaxSettings> 
                    <radA:AjaxSetting AjaxControlID="radSplitter">  
                        <UpdatedControls> 
                            <radA:AjaxUpdatedControl ControlID="radSplitter"></radA:AjaxUpdatedControl> 
                        </UpdatedControls> 
                    </radA:AjaxSetting>                 
                </AjaxSettings> 
                <ClientEvents OnRequestStart="RequestStart"/>  
            </radA:RadAjaxManager>            
        </div> 
        </form> 
    </body> 
    </html> 
     

    and the code behind is,

    using System;  
    using System.Data;  
    using System.Configuration;  
    using System.Collections;  
    using System.Web;  
    using System.Web.Security;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Web.UI.WebControls.WebParts;  
    using System.Web.UI.HtmlControls;  
     
    public partial class Default2 : System.Web.UI.Page  
    {  
        protected void Page_Load(object sender, EventArgs e)  
        {  
     
            //Telerik.WebControls.RadToolbarButton tbBtnMore =  
            //   tbrButtons.Items.GetButtonByCommandName("More");  
            //tbBtnMore.Attributes.Add("onClick", "if(!click_more()){return false;}");  
        }  
    }  
     

    Let me what is going wrong?

    Thanks.
  7. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 06 Aug 2008 Link to this post

    Hi Rose Garza,

    I'm sorry for the misunderstanding. Once we found you're actually using RadToolBar for ASP.NET "Classic", we were able to verify the problem.

    To my regret the problem occurred to be deeper than we expected and fixing it would take some more time. Would you instead consider switching to RadControls for ASP.NET Ajax? The new suite runs much faster and the architecture of the controls is much more intuitive.

    Looking forward to your reply,
    Erjan Gavalji
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017