AnneSKS
asked on
How to catch the result of a javascript confirm dialog box, for a C# onclick event
I have a user control that I used as a menu with image buttons, the delete button requires a confirmation before deleting.
I cannot use the confirmation extender as it creates a conflict with other telerik controls in my form.
I have started to use javascript to create the confirm message, however it does not matter if I confirm or cancel on the delete confirmation dialog box, the event is fired. How do I find out if the confirm is true or false?
This is what I have:
In the user control (ctl_Menu):
In the page containing the control:
aspx page:
aspx.cs page:
Thank you for your help
Anne
I cannot use the confirmation extender as it creates a conflict with other telerik controls in my form.
I have started to use javascript to create the confirm message, however it does not matter if I confirm or cancel on the delete confirmation dialog box, the event is fired. How do I find out if the confirm is true or false?
This is what I have:
In the user control (ctl_Menu):
public void Page_Load(object sender, EventArgs e)
{
this.btnDelete.Attributes.Add("onclick", "javascript: return confirm('Are you sure you want to delete this item?');");
}
In the page containing the control:
aspx page:
<sks:Menu ID="ctlMenu" runat="server"
ShowAdd="true" ShowSave="true" ShowDelete="true"
OnSave="ctlMenu_Save" OnAdd="ctlMenu_Add" OnDelete="ctlMenu_Delete" />
aspx.cs page:
protected void ctlMenu_Delete(object sender, EventArgs e)
{
ImageButton btn = (ImageButton)sender;
DeleteQuestion();
}
Thank you for your help
Anne
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I haven't closed this question yet, as I have tested your answer leakim 971 and it works very well on an image button, but I also want to make it work on a telerik Radbutton and haven't manage to make it work.
Any idea why?
Any idea why?
could you open a new thread? thanks
Open in new window
Here's an example, using pure HTML and jQuery: https://jsfiddle.net/zephyr_hex/hsm6ngse/1/