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

Calling client-side click event first followed by server-side click event

5 Answers 517 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Polaris431
Top achievements
Rank 1
Polaris431 asked on 21 Jan 2009, 08:21 AM
In a typical situation where you have a "Delete" button on the toolbar and the user presses it, you would first want to prompt the user whether they really want to perform the delete. If the user declines, the deletion is canceled. If they choose to delete, code on the server-side needs to be executed to carry out the delete. The toolbar does support the ButtonClick event. Is it possible to call this method from within a javascript function (where my prompting is carried out). Until now I have used the ajaxRequest method to send commands back to the server but I find this kind of ugly. It would be nice to use the method that is associated with the toolbar because some toolbar buttons will cause this event to be executed without going through a javascript function.

5 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2009, 12:31 PM
Hello,

You can try out the following code to display a confirm message on clicking a RadToolBarButton:
aspx:
<telerik:RadToolBar ID="RadToolBar1" Width="1000px" runat="server" OnButtonClick="RadToolBar1_ButtonClick"
        <Items> 
        <telerik:RadToolBarButton Text="SelectAll">                
        </telerik:RadToolBarButton> 
        <telerik:RadToolBarButton Text="DeleteAll" CommandName="DeleteSelected" ></telerik:RadToolBarButton> 
        <telerik:RadToolBarButton Text="Refresh" ></telerik:RadToolBarButton> 
        <telerik:RadToolBarButton Text="View" ></telerik:RadToolBarButton> 
        </Items> 
</telerik:RadToolBar> 

js:
<script type="text/javascript"
    function clientbuttonclick(sender, args) 
    { 
       
      var button = args.get_item(); 
            if (button.get_commandName() == "DeleteSelected") 
            { 
                args.set_cancel(!confirm('Delete all selected customers?')); 
            } 
    }     
 </script> 

cs:
 protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) 
    { 
        
    } 

Thanks
Princy.
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 06 Apr 2010, 05:34 PM
can someone help me with this, I cannot get this to work. here is my code, comfimation does not appear


 

<telerik:RadToolBar ID="RadToolBar1" runat="server" onbuttonclick="RadToolBar1_ButtonClick" Width="100%">  
    <Items> 
        <telerik:RadToolBarDropDown ToolTip="Add" Text="Add" Width="60px">  
            <Buttons> 
                <telerik:RadToolBarButton Enabled="true" Text="Elective Period" ToolTip="Add A Elective Period" Value="AddElective" /> 
                <telerik:RadToolBarButton Enabled="true" Text="Program Options" ToolTip="Add A Program Option" Value="AddProgram" /> 
                <telerik:RadToolBarButton Enabled="true" Text="Round" ToolTip="Add A Round" Value="AddRound" /> 
            </Buttons> 
        </telerik:RadToolBarDropDown> 
        <telerik:RadToolBarButton ToolTip="Edit ROL" Text="Edit" Width="60px" Value="EditROL">  
        </telerik:RadToolBarButton> 
        <telerik:RadToolBarButton ToolTip="Delete All ROL Child Records" Text="Delete" Width="60px" Value="DeleteROLChildren" CommandName="DeleteROLChildren" > 
        </telerik:RadToolBarButton> 
    </Items> 
</telerik:RadToolBar> 

 

<script type="text/javascript">  
    
    function clientbuttonclick(sender, args)    
    {    
          
        var button = args.get_item();    
        if (button.get_commandName() == "DeleteROLChildren")    
        {    
            args.set_cancel(!confirm('Are you sure you want to delete ALL ROL child records?'));    
        }    
    }    
          
 </script>  

 


got it, the example is missing

 

OnClientButtonClicking

 

="clientbuttonclick"

 

 

 

 

 

 

 

 

 

 

 

0
Stacy
Top achievements
Rank 1
answered on 19 Apr 2011, 03:50 PM
Where do you put "OnClientButtonClicking"?  It says it's not an event for RadToolbarButtons...
0
Andrew
Top achievements
Rank 1
Veteran
Iron
answered on 19 Apr 2011, 10:26 PM
0
Kate
Telerik team
answered on 21 Apr 2011, 11:19 AM
Hi Stacy,

Please refer to this forum thread.

Best wishes,
Kate
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
ToolBar
Asked by
Polaris431
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Andrew
Top achievements
Rank 1
Veteran
Iron
Stacy
Top achievements
Rank 1
Kate
Telerik team
Share this question
or