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

How to create some async client side functional on OnClientButtonClicking?

1 Answer 100 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Iliya
Top achievements
Rank 1
Iliya asked on 17 Oct 2010, 06:31 AM

I need to show up some confirm dialog when delete button's been just clicked and if user would click OK then make a common post back that will execute serverside functions.

I found an example:

01.<script language="javascript">
02.  
03.  function OnClientButtonClicked(sender, args)
04.  {
05.    
06.    var button = args.get_item();
07.    if(button.get_commandName() == 'Delete'){
08.        args.set_cancel(!confirm('Are you sure?'));
09.    }
10.  }   
11.  
12.</script>
13.  
14.  
15.    <telerik:RadToolBar ID="RadToolBar1" runat="server" 
16.        onbuttonclick="RadToolBar1_ButtonClick" Skin="Telerik" 
17.         OnClientButtonClicking="OnClientButtonClicked">
18.<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
19.        <Items>
20.            <telerik:RadToolBarButton runat="server" CommandName="Add" 
21.                ImageUrl="images/add.png" Text="Add New Client">
22.            </telerik:RadToolBarButton>
23.            <telerik:RadToolBarButton runat="server" CommandName="Edit" 
24.                ImageUrl="images/edit.png" Text="Edit Current Client">
25.            </telerik:RadToolBarButton>
26.            <telerik:RadToolBarButton runat="server" CommandName="Delete" 
27.                ImageUrl="images/delete.png" Text="Delete Selected Clients">
28.            </telerik:RadToolBarButton>
29.        </Items>
30.    </telerik:RadToolBar>

Well, and it do work pretty good, but i would like to use RadConfirmWindow instead of ugly native js confirm window.

I tried to realize it this way:

01.<script language="javascript">
02.    
03.  Function.prototype.withScope = function(scope) {
04.    return Function.createDelegate(scope, this);
05.  }
06.  
07.  function OnClientButtonClicked(sender, args)
08.  {
09.    
10.    var button = args.get_item();
11.    if(button.get_commandName() == 'Delete'){
12.        radconfirm('Are you sure?', 
13.            (function(arg){
14.                if(arg)
15.                    this.click();
16.            }).withScope(button), '250px', '100px', 'Confirmation');
17.          
18.    }
19.  }   
20.  
21.</script>
22.  
23.  
24.  
25.    <telerik:RadToolBar ID="RadToolBar1" runat="server" 
26.        onbuttonclick="RadToolBar1_ButtonClick" Skin="Telerik" 
27.         OnClientButtonClicked="OnClientButtonClicked">
28.<CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>
29.        <Items>
30.            <telerik:RadToolBarButton runat="server" CommandName="Add" 
31.                ImageUrl="images/add.png" Text="Add New Client">
32.            </telerik:RadToolBarButton>
33.            <telerik:RadToolBarButton runat="server" CommandName="Edit" 
34.                ImageUrl="images/edit.png" Text="Edit Current Client">
35.            </telerik:RadToolBarButton>
36.            <telerik:RadToolBarButton runat="server" CommandName="Delete" 
37.                ImageUrl="images/delete.png" Text="Delete Selected Clients" PostBack="false">
38.            </telerik:RadToolBarButton>
39.        </Items>
40.    </telerik:RadToolBar>

Seems that it should work but i get error: there is _no_ «click()» function belongs to button = args.get_item(); 

But its metioned it gotta exist — http://www.telerik.com/help/aspnet-ajax/tool_clientsidetoolbaritem.html


What am i doing wrong?

thanx

1 Answer, 1 is accepted

Sort by
0
Yana
Telerik team
answered on 19 Oct 2010, 11:21 AM
Hi Iliya,

Please check this kb article which explains how to achieve the needed approach.

All the best,
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
Tags
ToolBar
Asked by
Iliya
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or