16 Answers, 1 is accepted
0
Elliott
Top achievements
Rank 2
answered on 19 Jan 2011, 08:38 PM
OnClientClicking
Sets a name of a JavaScript function that will be called when the RadButton is clicked. The event is cancelable.
Sets a name of a JavaScript function that will be called when the RadButton is clicked. The event is cancelable.
0
Shinu
Top achievements
Rank 2
answered on 20 Jan 2011, 09:13 AM
Hello,
I followed Marianne's suggestion and the final code is shown below.
RadButton mark-up:
-Shinu.
I followed Marianne's suggestion and the final code is shown below.
<script type=
"text/javascript"
>
function
OnClientClicking(sender, args) {
var
callBackFunction = Function.createDelegate(sender,
function
(argument) {
if
(argument) {
this
.click();
}
});
var
text =
"Are you sure you want to submit the page?"
;
radconfirm(text, callBackFunction, 300, 100,
null
,
"Title"
);
args.set_cancel(
true
);
}
</script>
RadButton mark-up:
<
telerik:RadButton
ID
=
"btnToggle1"
CssClass
=
"RadButton"
runat
=
"server"
Text
=
"Checkbox 1"
OnClientClicking
=
"OnClientClicking"
ButtonType
=
"StandardButton"
OnClick
=
"btnToggle1_Click"
>
</
telerik:RadButton
>
-Shinu.
0
Brad
Top achievements
Rank 1
answered on 28 Feb 2011, 06:00 PM
Why do I get this in my console window?
args.set_cancel is not a function
0
Hello Brad,
Could you please verify that you have added the handler to the OnClientClicking event and not to the OnClientClicked event as the latter is not cancelable.
The general approach was outlined a few posts back, but for your convenience I will retrace the steps:
- Add a handler to the OnClientClicking event with the needed arguments (sender and args)
- In the function prompt the user to confirm the action (via the window.confirm() method for example)
- use the args.set_cancel() method with the negated result of the confirm as an argument to cancel the postback (or the assigned onClick action in your scenario).
More information and how to use RadAlert and RadWindow can be found in the new demo of RadButton.
Regards,
Marinthe Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Peter
Top achievements
Rank 1
answered on 09 May 2012, 06:15 AM
Thanks. But why not just have an property called "ConfirmText" or something like this to make this easier?
0
Hi Peter,
The RadConfirm that is used in the example is part of another control - the RadWindowManager. Adding such a property would require that the RadButton silently includes an entire control on the page along with its scripts and stylesheets. The functionality only consists of several lines of JavaScript that can even be easily reused between different buttons and they can also utilize an already existing manager on the page instead of adding a new one that can break some other functionality.
All the best,
Marin
the Telerik team
The RadConfirm that is used in the example is part of another control - the RadWindowManager. Adding such a property would require that the RadButton silently includes an entire control on the page along with its scripts and stylesheets. The functionality only consists of several lines of JavaScript that can even be easily reused between different buttons and they can also utilize an already existing manager on the page instead of adding a new one that can break some other functionality.
All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Peter
Top achievements
Rank 1
answered on 04 Jul 2013, 12:23 AM
I've come back to this article 1 year later and I still think there needs to be an easier way to implement a "Are you sure" confirm on a button click.
0
Princy
Top achievements
Rank 2
answered on 04 Jul 2013, 05:35 AM
Hi Peter,
Please try the following code snippet.
ASPX:
JS:
Please have a look at this Demo.
Hope this helps.
Thanks,
Princy
Please try the following code snippet.
ASPX:
<
telerik:RadWindowManager
ID
=
"RadWindowManager1"
runat
=
"server"
>
</
telerik:RadWindowManager
>
<
telerik:RadButton
AutoPostBack
=
"false"
ID
=
"RadButton1"
runat
=
"server"
Text
=
"RadButton"
OnClientClicked
=
"OnClientClicked"
>
</
telerik:RadButton
>
JS:
<script type=
"text/javascript"
>
function
OnClientClicked(button, args)
{
window.radconfirm(
"Are you sure you want to submit the page?"
);
}
</script>
Please have a look at this Demo.
Hope this helps.
Thanks,
Princy
0
Kien
Top achievements
Rank 1
answered on 12 Nov 2013, 12:20 AM
function
btnDelete_Clicking(sender, args) {
args.set_cancel(!confirm(
"Chắc chắn muốn xóa hợp đồng nà y ?"
));
}
0
Smartie
Top achievements
Rank 1
answered on 07 Jan 2014, 03:16 PM
Princy,
I have tried your code, I get the window. Pressing okay doesn't cause the button to do it's post back?
I have set auto post back to false, but are we meant to tell it to do the post back when they confirm it?
Regards
Leah
I have tried your code, I get the window. Pressing okay doesn't cause the button to do it's post back?
I have set auto post back to false, but are we meant to tell it to do the post back when they confirm it?
Regards
Leah
0
Hello Leah,
The following demo shows three ways to have such a confirmation for RadButton: http://demos.telerik.com/aspnet-ajax/button/examples/confirm/defaultcs.aspx. Please examine it to see how the controls are set up.
When using standard button types you first need to prevent the postback, then initiate in the callback function. This is explained in the following demo: http://demos.telerik.com/aspnet-ajax/window/examples/confirmserverclicks/defaultcs.aspx. The scripts file shows the different code for different button types and the demo description offers a detailed explanation.
Regards,
Marin Bratanov
Telerik
The following demo shows three ways to have such a confirmation for RadButton: http://demos.telerik.com/aspnet-ajax/button/examples/confirm/defaultcs.aspx. Please examine it to see how the controls are set up.
When using standard button types you first need to prevent the postback, then initiate in the callback function. This is explained in the following demo: http://demos.telerik.com/aspnet-ajax/window/examples/confirmserverclicks/defaultcs.aspx. The scripts file shows the different code for different button types and the demo description offers a detailed explanation.
Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
Smartie
Top achievements
Rank 1
answered on 07 Jan 2014, 03:42 PM
I would love to use the first example in the first link you have given.
I get the following error when trying to set a value to onClick.
Error 3 'Telerik.Web.UI.RadButton.Protected Overridable Sub OnClick(e As Telerik.Web.UI.ButtonClickEventArgs)' is not accessible in this context because it is 'Protected'.
My control is dynamically added to the page.
I get the following error when trying to set a value to onClick.
Error 3 'Telerik.Web.UI.RadButton.Protected Overridable Sub OnClick(e As Telerik.Web.UI.ButtonClickEventArgs)' is not accessible in this context because it is 'Protected'.
My control is dynamically added to the page.
0
Shinu
Top achievements
Rank 2
answered on 08 Jan 2014, 04:26 AM
Hi,
Please have a look into the following code snippet to show a Confirm on dynamically created RadButton click.
C#:
Hope this will helps you.
Thanks,
Shinu.
Please have a look into the following code snippet to show a Confirm on dynamically created RadButton click.
C#:
protected
void
Page_Load(
object
sender, EventArgs e)
{
RadButton Button =
new
RadButton();
Button.ID =
"btnStandardConfirm"
;
Button.Text =
"Standard window.confirm"
;
Button.OnClientClicking =
"StandardConfirm"
;
Button.Click+=
new
EventHandler(Button_Click);
this
.form1.Controls.Add(Button);
}
protected
void
Button_Click(
object
sender, EventArgs e)
{
RadButton btn = sender
as
RadButton;
switch
(btn.ID)
{
case
"btnStandardConfirm"
:
Label1.Text =
"The <strong>StandardButton</strong> submitted the page at: "
+ DateTime.Now.ToString();
break
;
}
}
Hope this will helps you.
Thanks,
Shinu.
0
Smartie
Top achievements
Rank 1
answered on 17 Feb 2014, 02:24 PM
Thank you, I have now gotten it working :)
0
Dustin
Top achievements
Rank 1
answered on 21 May 2015, 08:31 PM
As Peter suggested, why not add a ConfirmText property to the RadButton, just like the GridButtonColumn?
0
Hi Guys,
I have logged this feature request in our feedback portal here (http://feedback.telerik.com/Project/108/Feedback/Details/159170), so that you can monitor, comment and vote on it. As more and more people vote on the item its priority for implementation raises.
Regards,
Danail Vasilev
Telerik
I have logged this feature request in our feedback portal here (http://feedback.telerik.com/Project/108/Feedback/Details/159170), so that you can monitor, comment and vote on it. As more and more people vote on the item its priority for implementation raises.
Regards,
Danail Vasilev
Telerik
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 Feedback Portal
and vote to affect the priority of the items