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

Server onbuttonclick only firing once

10 Answers 249 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Sean
Top achievements
Rank 1
Sean asked on 10 Feb 2009, 09:51 AM
Hi,

I have the following RadToolBar within a user control :
   <telerik:radtoolbar id="rtbToolBar" runat="server" skin="Office2007" borderstyle="None" 
      width="100%" onbuttonclick="rtbToolBar_ButtonClick" onclientbuttonclicking="toolbarClicking">  
                              </telerik:radtoolbar> 

Buttons are then added programatically.

The problems is, the serverside button click event only fires the first time that a button is clicked.  After that, nothing happens.
The clientside onclientbuttonclicking event still fires.
As a test I have placed an asp button in the control with the radtool bar.  The buttons click event fires succefully each time.

I would very much appreciate some help with this issue, it's driving me crazy!

Thanks,

Sean Duffy

10 Answers, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 10 Feb 2009, 03:40 PM
Hello Sean,

I tested ButtonClick event and wasn't able to reproduce this issue - it fires as expected.

Regards,
Yana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Sean
Top achievements
Rank 1
answered on 12 Feb 2009, 04:57 PM
I am still experiencing the problem described.  Unfortunately this issue is of such a serious nature that if we are unable to resolve it, we may be unable to use the Telerik controls and therefore it would not be worth purchasing the full license.

In detail, this is the problem we are experiencing.

As previously described,  we have the following RadToolBar within a user control.
This control is added to the MasterPage.

<telerik:radtoolbar id="rtbToolBar" runat="server" skin="Office2007" borderstyle="None"  
      width="100%" onbuttonclick="rtbToolBar_ButtonClick" onclientbuttonclicking="toolbarClicking">   
                              </telerik:radtoolbar>  

We are then adding a range off buttons :

rtbToolBar.Items.AddRange(ToolbarHelper.GetButtonsForView(OwnerType.ToString())); 
(GetButtonsForView returning List<RadToolBarItems>)

If the OwnerType of the toolbar changes, then we call :

 rtbToolBar.Items.Clear(); 

before adding the next range of buttons in the manner described previously.

After this point, the buttons within the ToolBar no longer generate server post backs.
If you require more information, then please let me know.

Regards,

Sean Duffy





0
Yana
Telerik team
answered on 16 Feb 2009, 12:31 PM
Hello Sean,

I tested the provided code and still am not able to observe this issue. I've attached my test page, please download it and give it a try. What is different in your case? Could you modify it and send it back? You should open a support ticket in order to attach files. Thanks

Regards,
Yana
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
Cristian Malinescu
Top achievements
Rank 1
answered on 15 Jun 2010, 10:36 PM
I experience the same problem; the provided sample uses an aspx page BUT the problem mentions that the context of the error is an ascx user control - this is the same context I experience it. This is my code

ascx user control:
     <telerik:RadToolBar id = "_X_ToolBar_"                                                            
                         OnButtonClick = "_X_ToolBar_Click"                         
                         Width = "100%" runat="server"
       <Items> 
         <telerik:RadToolBarButton IsSeparator = "true" runat="server"/> 
                           
         <telerik:RadToolBarButton ImageUrl = "~/Images/16x16/plain/save_x.png"  
                                   ToolTip = "Save selected X" 
                                   Text = "Save" 
                                   Value = "Save" 
                                   CommandName = "Save" /> 
                                         
         <telerik:RadToolBarButton IsSeparator = "true" runat="server"/>                                         
       </Items> 
     </telerik:RadToolBar>                        

ascx code behind:
  Protected Sub _X_ToolBar_Click(ByVal sender As ObjectByVal e As RadToolBarEventArgs) 
    Dim item As RadToolBarItem = e.Item 
    Dim value As String = item.Value 
 
    If Flow.Save.ToString.Equals(value) Then 
      SaveX() 
    End If 
  End Sub 

_X_ToolBar_Click(...) method does not get fired - ever.
 
0
Yana
Telerik team
answered on 16 Jun 2010, 10:15 AM
Hello Cristian,

Can you tell us how you load this user control in the page? If it's loaded dynamically, it should be added on every postback with the same id. Please check this and let us know the result.

Greetings,
Yana
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Cristian Malinescu
Top achievements
Rank 1
answered on 16 Jun 2010, 03:33 PM

Thanks Yana; so the scenario is like this:
- In one aspx page I have a RadSplitter with two zones - left and right, both being RadPane containers.
- The left RadPane contains a RedTreeView I call the *model navigator*; each element of the tree can represent a different 
  model part depending on the hierarchy level.  
- Selecting in the navigator tree one node triggers a server side callback for the OnNodeClick event.
- In the callback, the right model is identified based on the node hierarchal level and the right entity is instantiated based on the identifier stored in the node.
- Now, in the right RadPane I call the model workspace it is supposed to load dynamically the presentation template of the corresponding model part. Each model part has its own presentation template defined as an user control/ascx component.
The aspx code doing it looks this way

       Protected Sub _X_TreeView_NodeClick(ByVal sender As ObjectByVal e As RadTreeNodeEventArgs)  
          If e.Node IsNot Nothing Then 
            If GetType(X).ToString().Equals(e.Node.Category()) Then 
              Dim x_ As X = New X()  
              convertFromTreeNode(x_, e.Node)  
              loadXTemplate(x_)  
            End If 
          End If 
        End Sub 
          
        Private Sub loadXTemplate(ByRef x_ As X)  
          If x_ IsNot Nothing Then 
            Try 
              Dim t_ As XTemplate = DirectCast(LoadControl(XTemplate.Meta.URL), XTemplate)  
                  
              If t_ IsNot Nothing Then 
                _XTemplate_Frame_Pane_.Controls.Add(t_)  
              End If              
            Catch ex As Exception  
              log(ex)  
              Throw ex  
            Finally 
          End If 
        End Sub       
         

Now, the model template has its own actions triggered from a RadToolBar belonging to the ascx template - not the owning aspx page, and the action callback is defined into the ascx code behind as a callback attached to the toolbar OnButtonClick event. When one action of the toolbar gets triggered it is first intercepted by the _LOAD handler of the owning aspx page but it doesn't get chained to the declared toolbar callback.

Is there a better a way to make the RadPane controls collection - maybe a better flow, to keep aware of the control added dynamically? I noticed the controls collection gets emptied after clicking one toolbar button in the template; the problem is that in _PreInit, _Init, _Load stages of the owning aspx page there is no way - as far as I could find, to discover/identify which element of the tree got selected so that I can be proactive and load the right template; this information gets revealed only at the stage when the treenode click handler is executed in the flow.

Cheers,
Cris

0
Yana
Telerik team
answered on 22 Jun 2010, 01:36 PM
Hello Cristian,

As I explained earlier dynamic controls should be added on every postback - this may be the reason that the event is not fired. I've attached a simple page and 2 simple user controls based on your description to show you that the event is fired without a problem. Please download the example and examine it.

Greetings,
Yana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Cristian Malinescu
Top achievements
Rank 1
answered on 22 Jun 2010, 03:07 PM

I agree as I know this for long time - and I used it this way. What I expected from Telerik as a framework is to go behind the default platform features and lifecycle - at the end it is a framework and not only a decorator layer on top of the platform defaults, and provide an API attached to the RadPane - I think most people expect it to be like this where eventual dynamically added content becomes known to the owner widget and integrated into its lifecycle and state; otherwise it is nothing else but pure text injection the client/consumer API has to take care of it always - so, the question is then, why use anymore RadPane when the same can be achieved with div, css and JQuery?! If this state and lifecycle integration is indeed supported by RadPane – I couldn’t find it into any of the API reference provided by Telerik – maybe someone can point to it or put an example in the control examples page? For a presentation framework supposedly meant to support dynamic web applications it is crucial to provide widgets able to integrate one with another in a flow graph and lifecycle otherwise these widgets are nothing else but tiny text renderers with a limited state management defaulting always to the platform one. For achieving this simple text rendering with enclosed state management just light template solutions are much more efficient, like for exmaple http://www.stringtemplate.org/.

0
T. Tsonev
Telerik team
answered on 23 Jun 2010, 09:47 AM
Hi Cristian,

Thank you for sharing your feedback with us.

The goal of RadControls for ASP.NET AJAX is not to construct a separate framework of our own, but to provide ready-to-use components for the ASP.NET AJAX Framework. We try to improve it and build upon it with controls like RadAjax, RadScriptManager and RadStyleSheetManager, but we can't change any of it basic principles. The relatively complex control lifecycle is such fundamental part of the framework.

You're, of course, free to mix RadControls with any other server-side or client-side techniques to achieve your goals. We can even recommend using ASP.NET MVC and our excellent extensions for it in order to achieve more fine grained control.

I hope this helps.

Regards,
Tsvetomir Tsonev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Cristian Malinescu
Top achievements
Rank 1
answered on 23 Jun 2010, 04:22 PM

Thank you Tsvetomir - this is the answer I was looking for driving further our development requirements and measure the amount of support Telerik RadControl framework can offer us. In this case, maybe we will look into the additional Telerik frameworks to plug together with RadControls for getting a better bang.

Cheers,
Cris

Tags
ToolBar
Asked by
Sean
Top achievements
Rank 1
Answers by
Yana
Telerik team
Sean
Top achievements
Rank 1
Cristian Malinescu
Top achievements
Rank 1
T. Tsonev
Telerik team
Share this question
or