Вопрос

So I have a Hyperlink on my asp.net page. When the person clicks that link, it carries out some action. Now I want to be able to add a javascript alert (confirm, actually) as to whether the user is SURE he/she wants to carry out the action? If yes, then carry out the action, otherwise do nothing. How do I do this?

My current code just has a link to the action:

Link1.NavigateUrl = "./Actions.aspx?action=abort&job=" + JobID;
Это было полезно?

Решение

I'm not at my development environment to test this out, but something like this should work for you:

Link1.NavigateUrl = "./Actions.aspx?action=abort&job=" + JobID;
Link1.Attributes["onclick"] = "return confirm('Are you sure?');";
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top