This is a migrated thread and some comments may be shown as answers.

toolbar posting back twice

16 Answers 119 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Andrew Knowles
Top achievements
Rank 1
Andrew Knowles asked on 22 Jul 2008, 01:10 PM
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

16 Answers, 1 is accepted

Sort by
0
kmv
Top achievements
Rank 1
answered on 15 May 2009, 02:38 PM
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
0
Erjan Gavalji
Telerik team
answered on 15 May 2009, 03:05 PM
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.
0
kmv
Top achievements
Rank 1
answered on 15 May 2009, 03:33 PM
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 !!







0
Erjan Gavalji
Telerik team
answered on 15 May 2009, 03:36 PM
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.
0
kmv
Top achievements
Rank 1
answered on 15 May 2009, 03:38 PM
well i can but the toolbar is the only thing on the page , (see the aspx) but i will check it anyway :-)


kevin
0
kmv
Top achievements
Rank 1
answered on 15 May 2009, 03:40 PM
hmmmm it doesnt happen in firefox... only ie (6)



kevin
0
Erjan Gavalji
Telerik team
answered on 15 May 2009, 04:47 PM
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.
0
kmv
Top achievements
Rank 1
answered on 15 May 2009, 05:10 PM
ie7 does it too.. i will parcel up the one file project


thanks
kevin
0
Brian
Top achievements
Rank 1
answered on 02 Oct 2009, 08:22 PM
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.
0
Simon
Telerik team
answered on 07 Oct 2009, 10:06 AM
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.
0
John Caldwell
Top achievements
Rank 1
answered on 23 Nov 2009, 01:13 AM
This seems to happen if you have a RadAjaxPanel on the page. The toolbar click event is posted back twice.
0
Simon
Telerik team
answered on 23 Nov 2009, 04:06 PM
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.
0
Steve Carpenter
Top achievements
Rank 1
answered on 31 Dec 2010, 05:31 PM
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.
0
Simon
Telerik team
answered on 04 Jan 2011, 03:48 PM
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.
0
Steve Carpenter
Top achievements
Rank 1
answered on 04 Jan 2011, 03:59 PM
Thanks Simon.  I did not even notice that.  Guess I should have used a switch....
0
Simon
Telerik team
answered on 04 Jan 2011, 04:15 PM
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.
Tags
ToolBar
Asked by
Andrew Knowles
Top achievements
Rank 1
Answers by
kmv
Top achievements
Rank 1
Erjan Gavalji
Telerik team
Brian
Top achievements
Rank 1
Simon
Telerik team
John Caldwell
Top achievements
Rank 1
Steve Carpenter
Top achievements
Rank 1
Share this question
or