toolbar posting back twice

17 posts, 0 answers
  1. Andrew Knowles
    Andrew Knowles avatar
    42 posts
    Member since:
    Aug 2006

    Posted 22 Jul 2008 Link to this post

    When clicking on a button on toolbar its posting back twice code is:

    <rad:RadToolbar ID="RadToolbarCustomer" style="position:absolute; left: 790px; top: 130px;" runat="server" skinspath="/XLogix/RadControls/ToolBar/Skins/" skin="XLogixBlue" AutoPostBack="true"

    ImagesDir="/XLogix/RadControls/ToolBar/Skins/XLogixBlue/img/" OnOnClick="RadToolBar_OnClick">

    <Items>

    <rad:RadToolbarButton id="CreateButton" commandname="Create" DisplayType="TextImage" ButtonText="Create" ButtonImage="add_24.gif" tooltip="Create new order for this customer" width="90px" runat="server"/>

    <rad:RadToolbarButton id="UpdateButton" commandname="Update" DisplayType="TextImage" ButtonText="Update" ButtonImage="add_24.gif" tooltip="Update order for this customer" width="90px" runat="server"/>

    </Items>

    </rad:RadToolbar>

    this other toolbar on the same page does not have the same problem both using the same onclick event handler 
    <
    rad:RadToolbar ID="RadToolbarProduct" style="position:absolute; left: 570px; top: 620px;" runat="server" skinspath="/XLogix/RadControls/ToolBar/Skins/" skin="XLogixBlue" AutoPostBack="true"

    ImagesDir="/XLogix/RadControls/ToolBar/Skins/XLogixBlue/img/" OnOnClick="RadToolBar_OnClick" Enabled="False" >

    <Items>

    <rad:RadToolbarButton id="DeleteBtn" commandname="Delete" DisplayType="TextImage" ButtonText="Delete" ButtonImage="remove_24.gif" tooltip="Delete item from order" width="90px" Enabled="False" Hidden="False" runat="server"/>

    <rad:RadToolbarButton id="AddBtn" commandname="Add" DisplayType="TextImage" ButtonText="Add" ButtonImage="add_24.gif" tooltip="Add item to order" width="90px" Enabled="False" Hidden="False" runat="server"/>

    <rad:RadToolbarButton id="NewBtn" commandname="New" DisplayType="TextImage" ButtonText="New" ButtonImage="add_24.gif" tooltip="Create item to add to order" width="90px" Enabled="False" Hidden="False" runat="server"/>

    <rad:RadToolbarButton id="DoneBtn" commandname="Done" DisplayType="TextImage" ButtonText="Done" ButtonImage="add_24.gif" tooltip="Complete Order" width="90px" Enabled="False" Hidden="False" runat="server"/>

    </Items>

    </rad:RadToolbar>

    This problem occurs if i have ajax on or off toolbar dll version is 1.6.5.0

  2. kmv
    kmv avatar
    53 posts
    Member since:
    Apr 2008

    Posted 15 May 2009 Link to this post

    did anyone answer this.. because i am seeing it with 2009.1 toolbar

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="essential3.WebForm1" %>
    <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>
    <!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></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
            </telerik:RadScriptManager>
            <telerik:RadToolBar ID="RadToolBar1" Runat="server">
                <Items>
                    <telerik:RadToolBarButton runat="server" NavigateUrl="~/Webform1.aspx"
                        PostBack="False" Text="Button 0">
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>
            
        </div>
        </form>
    </body>
    </html>


    and the form load event runs twice


    thanks
    kevin
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 15 May 2009 Link to this post

    Hi guys,

    Do you mean that the ButtonClick eventhandler for the RadToolBar is called twice? If this is the case, could it be that you keep a reference to the RadToolBar instance in the Session? RadControls should not be stored in the Session, because of possible memory leaks and other problems (like having the event raised twice - once for the old instance and one for the new one).

    If this is not the case, is it possible for you to prepare a small sample project and send it to us for testing (you could use your project if it is small one as well)?

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. kmv
    kmv avatar
    53 posts
    Member since:
    Apr 2008

    Posted 15 May 2009 Link to this post

    no the page_load event is getting called twice ...

    the aspx code is above and the c# code is just

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    namespace essential3
    {
        public partial class WebForm1 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                int x = 1;
            }
        }
    }


    if i click the button on the tool bar int x = 1 breakpoint gets hit twice !!







  6. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 15 May 2009 Link to this post

    Hi kmv,

    I get it now. Can you please, use the Firebug tool for Firefox, or the Fiddler tool for Internet Explorer to check if there are any other requests to the page? It is possible that some image or some <link> tag try to access the page URL.

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  7. kmv
    kmv avatar
    53 posts
    Member since:
    Apr 2008

    Posted 15 May 2009 Link to this post

    well i can but the toolbar is the only thing on the page , (see the aspx) but i will check it anyway :-)


    kevin
  8. kmv
    kmv avatar
    53 posts
    Member since:
    Apr 2008

    Posted 15 May 2009 Link to this post

    hmmmm it doesnt happen in firefox... only ie (6)



    kevin
  9. Erjan Gavalji
    Admin
    Erjan Gavalji avatar
    1455 posts

    Posted 15 May 2009 Link to this post

    Hi kmv,

    Strange indeed, I just tested the same ASPX and the codebehind with IE6 and I did not have the problem...

    Can you send us the ASPX file, its codebehind file and the designer file for a test (please use a formal support ticket to attach the files).

    Kind regards,
    Erjan Gavalji
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. kmv
    kmv avatar
    53 posts
    Member since:
    Apr 2008

    Posted 15 May 2009 Link to this post

    ie7 does it too.. i will parcel up the one file project


    thanks
    kevin
  11. Brian
    Brian avatar
    2 posts
    Member since:
    Dec 2008

    Posted 02 Oct 2009 Link to this post

    Any resolution to this?

    I'm having the same problem. My RadToolbar is in a user control and uses the NavigateUrl="nextpage.aspx" on the buttons to go the next page. When debugging, the "nextpage.aspx" Page_Load() event handler is executed twice as if there are two requests being generated.

    This seems to be isolated to IE (I'm running IE7). Works fine in Firefox and Chrome.

    I'm running version v2.0.50727.
  12. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 07 Oct 2009 Link to this post

    Hello Brian,

    We haven't managed to reproduce this issue yet.

    Can you try isolating it in a single page only with one RadToolBar on it? Or is there something else needed in order to reproduce the issue?

    Best wishes,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  13. John Caldwell
    John Caldwell avatar
    2 posts
    Member since:
    Jan 2009

    Posted 22 Nov 2009 Link to this post

    This seems to happen if you have a RadAjaxPanel on the page. The toolbar click event is posted back twice.
  14. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 23 Nov 2009 Link to this post

    Hi John Caldwell,

    I tried reproducing the issue without success in the simple page I attached to this message.

    Can you have a look at the page and let me know what I am missing?

    Kind regards,
    Simon
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  15. Steve Carpenter
    Steve Carpenter avatar
    2 posts
    Member since:
    Feb 2010

    Posted 31 Dec 2010 Link to this post

    I realize this is an old post, but in case anyone is still encountering this problem, what worked for me was "returning" out of "RadToolBar1_ButtonClick".   By way of a pared down example, say you have a toolbar:
    <telerik:RadToolBar runat="server" ID="RadToolBar1" OnButtonClick="RadToolBar1_ButtonClick">
       <Items>
          <telerik:RadToolBarButton Text="Show Messages For All Users" runat="server" CommandName="FilterMessages" CommandArgument="All">
          </telerik:RadToolBarButton>
       </Items>
    </telerik:RadToolBar>

    and in the code behind:
     
    protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
    {
      
    RadToolBarButton button = e.Item as RadToolBarButton;
      
    if (button.CommandName == "FilterMessages")
         
    {
             
    if (button.CommandArgument == "All")
                  {
                  
    button.Text = "Show Only My Messages";
                  
    button.CommandArgument = "Mine";
                  
    return;
                  }
             
    if (button.CommandArgument == "Mine")
                  {
                  
    button.Text = "Show Messages For All Users";
                  
    button.CommandArgument = "All";
                  
    return;
                  }
          }
    }

    The two return statements prevent "RadToolBar1_ButtonClick" from executing a second time after postback.
  16. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 04 Jan 2011 Link to this post

    Hi Steve,

    When you click on the "All" button both if-bodies in the Click handler execute. Perhaps this gives the impression that the handler executes twice and putting the return statements works.
    protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e)
    {
       RadToolBarButton button = e.Item as RadToolBarButton;
       if (button.CommandName == "FilterMessages")
          {
              if (button.CommandArgument == "All")
                  {
                   button.Text = "Show Only My Messages";
                   button.CommandArgument = "Mine";
                   return;
                  }
              if (button.CommandArgument == "Mine")
                  {
                   button.Text = "Show Messages For All Users";
                   button.CommandArgument = "All";
                   return;
                  }
          }
    }

    I hope this sheds some more light on the subject.

    Kind regards,
    Simon
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  17. Steve Carpenter
    Steve Carpenter avatar
    2 posts
    Member since:
    Feb 2010

    Posted 04 Jan 2011 Link to this post

    Thanks Simon.  I did not even notice that.  Guess I should have used a switch....
  18. Simon
    Admin
    Simon avatar
    2281 posts

    Posted 04 Jan 2011 Link to this post

    Hi Steve,

    Yes, a switch fits perfectly in this case.

    Have a great and productive week!

    Regards,
    Simon
    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