r.a.d.toolbar and r.a.d.window integration

Thread is closed for posting
11 posts, 0 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 21 Dec 2006 Link to this post

    Requirements

    r.a.d.controls version

    r.a.d.toolbar 1.4
    r.a.d.window 1.7

    .NET version

    2.0

    Visual Studio version

    2005

    programming language

    C#

    browser support

    all browsers supported by r.a.d.toolbar
    and r.a.d.window


     
    PROJECT DESCRIPTION
    This project shows how to open client side a window dialog depending on the clicked toolbar button. We check which button is clicked through its CommandName value. Sender is a parameter in the toolbar click handler and returns an instance of the clicked toolbar button.
    There are two aspx pages: radConfirm.aspx and radWindow.aspx which show how to open a confirm dialog and a window respectively.  
  2. BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6
    BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6 avatar
    131 posts
    Member since:
    Nov 2006

    Posted 18 Jan 2007 Link to this post

    Thanks for this great example. It's very close to what I need, but there is a problem with it when Ajax is involved.

    Let's assume that the toolbar is in a RadAjaxPanel, and there are two buttons on it, one that opens a RadWindow and one that is a toggle button which does an async postback. When the toggle button is clicked then the panel refreshes with the "open a window" toolbar button having a new ClientID. The attachEvent call needs to be called again in this scenerio. At this point its Javascript will not fire on a click event because the event handler is no longer attached.

    What's the be strategy for handling this? Which event do you re-do the attachEvent in?

    Thanks,

    Terry

  3. 8AECA7A5-3E26-4708-AD62-47AA92940523
    8AECA7A5-3E26-4708-AD62-47AA92940523 avatar
    6637 posts
    Member since:
    Sep 2012

    Posted 19 Jan 2007 Link to this post

    Hello Terry,
                     
    Thank you for your question. Actually, this is a known issue when integrating r.a.d.toolbar with r.a.d.ajax. Please, view the help topic on Client events are unattached after ajax update which shows how to solve the problem. 

        
                     
    Greetings,
    Peter
    the telerik team
  4. BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6
    BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6 avatar
    131 posts
    Member since:
    Nov 2006

    Posted 19 Jan 2007 Link to this post

    Thanks for your reply. Reattaching the event handlers in the RadAjaxPanel's OnResponseEnd is one step closer, but it still doesn't resolve the issue.

    In my case the toolbar is part of a control which is on a page with a higher-level Ajax panel. Specifically, it's an Atlas UpdatePanel in my case but it could potentially be either one. When this page-level ajax panel is refreshed the event handlers are lost again. Handling the event reattachments at the higher level is not an option since the control should be an independent component. Also, there could theoretically be any level of nested Ajax panels.

    Also, this solution only works with the RadAjaxPanel since the Atlas UpdatePanel doesn't have an equivalent to ClientEvents-OnResponseEnd (as far as I know). You can do the same using an event on the asp:ScriptManager, but once again, that's not an option for reusable controls or very good when the ScriptManager is in the MasterPage which it is in my case.

    Is there not any way to call a javascript function to launch a RadWindow directly from the button on the toolbar without having to go through a toolbar-level click event? In other words, something that would always be "wired up"?

    Thanks again,
    Terry
  5. CEE486A7-FA5A-432A-A744-07A4F262C400
    CEE486A7-FA5A-432A-A744-07A4F262C400 avatar
    1052 posts
    Member since:
    Jan 2017

    Posted 22 Jan 2007 Link to this post

    Hi Terry,

    You can run any javascript code after the MS Ajax update using the following syntax:

    <script type="text/javascript">  
                          
    var prm = Sys.WebForms.PageRequestManager.getInstance();  
    prm.add_endRequest(OnEndRequest);  
                          
    function OnEndRequest(sender,args)  
    {                              
        alert("Microsoft Ajax has just finished updating the page!");        
    }  
    </script> 
     

    We have a blog post also regarding this scenario for both r.a.d.ajax and MS Ajax. 
    Hope it will be helpful.

    Kind regards,
    Helen
    the telerik team
  6. BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6
    BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6 avatar
    131 posts
    Member since:
    Nov 2006

    Posted 18 Jan 2008 Link to this post

    I originally posted this in the RadToolbar forum and then moved it here after realizing it is related to all of the above. In short, the solution as described above in this thread is not working with VS2008 and .NET 3.5.


    ______________________________________________________
    I have a RadToolbar on a charting user control. I have javascript within the control that attaches client-side events to the toolbar. Since moving to VS 2008 I am getting a "Negating the minimum value of a twos complement number is invalid." error. I don't know if this was ignore before and VS 2008 is breaking on the error now?

    Here is my code:

    <script type="text/javascript"
    // On page load add a "end request" Microsoft AJAX event handler. 
    var ajaxManager = Sys.WebForms.PageRequestManager.getInstance(); 
    ajaxManager.add_endRequest(chartPanel_OnEndRequest); 
     
    // Bind script events on page load. 
    bindClientEvents(); 
     
    // Client events must be bound on each ajax refresh. 
    function chartPanel_OnEndRequest(sender, arguments) 
       bindClientEvents(); 
     
    // Bind the toolbar to its event handlers. 
    function bindClientEvents() 
       // THIS LINE THROWS THE ERROR. toolbar.ClientID is highlighted by the IDE. 
       <%= toolbar.ClientID %>.attachEvent("OnClientClick", "toolbarClickHandler");  

    In this particular case, the toolbar has Visible = False. So it makes sense that the toolbar doesn't exist on the page and that may be what is causing the weird error. I replaced the bindClientEvents() logic with this:

    // Bind the toolbar to its event handlers. 
    function bindClientEvents() 
       var findToolbar = document.getElementsByName('<%= toolbar.ClientID %>'); 
        
       if (findToolbar.length > 0) 
       { 
            findToolbar(0).attachEvent("OnClientClick", "toolbarClickHandler");  
       } 

    However, it didn't help. The same error now occurs on the getElementsByName line.

    Any suggestions?

    Thank you,
    Terry
  7. 6C23224E-CB71-4D12-B58E-CA28ABCBD735
    6C23224E-CB71-4D12-B58E-CA28ABCBD735 avatar
    8462 posts
    Member since:
    Nov 2015

    Posted 21 Jan 2008 Link to this post

    Hello,

    Please try the following code:

    function bindClientEvents()
    {
       var toolbar = <%= toolbar.ClientID %>;
       if (toolbar)
       {
            toolbar.attachEvent("OnClientClick", "toolbarClickHandler"); 
       }
    }

    By adding the "if" statement you would make sure no JavaScript error is thrown when the toolbar is not visible on the page.

    Regards,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  8. BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6
    BE764AEB-AD66-4D2B-8D4F-8635D03FA0F6 avatar
    131 posts
    Member since:
    Nov 2006

    Posted 21 Jan 2008 Link to this post

    Thank you for the help, but after trying it I am still getting this error:

    "Negating the minimum value of a twos complement number is invalid."

    on the line:

    var toolbar = <%= toolbar.ClientID %>;

    I don't think the problem is as simple as skipping some Javascript when the toolbar is not visible on the page because we never got this exception before. We've made two major architectural changes recently that I think may be involved. We moved to VS 2008 and .NET 3.5, and we started using some Prometheus controls as well.

    Do you know if this error could be related to either of those?

    Thank you,
    Terry
  9. 6C23224E-CB71-4D12-B58E-CA28ABCBD735
    6C23224E-CB71-4D12-B58E-CA28ABCBD735 avatar
    8462 posts
    Member since:
    Nov 2015

    Posted 22 Jan 2008 Link to this post

    Hello,

    This error message has not been reported so far. Could you please open a support ticket and send us your project? This will help us reproduce the problem and see what is wrong. Thanks.

    Sincerely yours,
    Albert
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  10. 597AC799-7CFC-4292-B485-DD08E8542AA7
    597AC799-7CFC-4292-B485-DD08E8542AA7 avatar
    3 posts
    Member since:
    Nov 2007

    Posted 23 Jan 2008 Link to this post

    Hi

    I'm facing a similar isssue. Please keep me posted on this issue as well.

    Thanks,
    Mahyar
  11. F8D2C2D7-C576-4590-ADB2-EDA5C20DF770
    F8D2C2D7-C576-4590-ADB2-EDA5C20DF770 avatar
    3 posts
    Member since:
    Oct 2006

    Posted 10 Jun 2009 Link to this post

    Try this one

     

     

     var toolbar = $find("<%= RadTooblar2.ClientID %>");  
               if (toolbar)  
               {  
                    toolbar.attachEvent("OnClientClick", "toolbarClickHandler");    
               } 

     

Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.