ASPX:
<telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"> </telerik:RadWindowManager> <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> var lastClickedItem = null; var clickCalledAfterRadprompt = false; var clickCalledAfterRadconfirm = false; function onClientButtonClicking(sender, args) { if (args.get_item().get_text() == "Order another beer") { if (!clickCalledAfterRadconfirm) { args.set_cancel(true); lastClickedItem = args.get_item(); radconfirm("Are you sure? You order it, you finish it!", confirmCallbackFunction); } } } function confirmCallbackFunction(args) { if (args) { clickCalledAfterRadconfirm = true; lastClickedItem.click(); } else clickCalledAfterRadconfirm = false; lastClickedItem = null; } </script> </telerik:RadCodeBlock> <CommandItemTemplate> <telerik:RadToolBar ID="RadToolBar1" runat="server" OnClientButtonClicking="onClientButtonClicking" OnButtonClick="RadToolBar1_ButtonClick" Width="100%"> <CollapseAnimation Duration="200" Type="OutQuint" /> <Items> <telerik:RadToolBarButton CommandName="OrderBeer" runat="server" Text="Order another beer"></telerik:RadToolBarButton> </Items> </telerik:RadToolBar> </CommandItemTemplate>
The CommandItemTemplate part you obviously need to add to your MasterTableView element..
CS:
protected void RadToolBar1_ButtonClick(object sender, RadToolBarEventArgs e) { RadToolBarButton button = e.Item as RadToolBarButton; if (button.CommandName == "OrderBeer") { \\Do stuff, drink the beer \\DrinkBeer(); } }
Have a nice weekend folks!!!
Hello thanks for the post, now I got some real light in this ...but, I tried to do the sames with a asp button and dont work the same way of the radtoolbar. any thoughts?
ReplyDeleteHi Davey,
ReplyDeleteFor an ordinary asp button things are a lot easier.
1. Create a javascript function which returns a boolean, for example:
function ConfirmOrder()
{
// your business logics.. or really simple example:
return confirm("Do you really want to order?");
}
2. Add the function call to the OnClientClick of your button:
So, if the 'confirm' function returns 'false', the server side method 'btnOrder_Click' will not be executed.