How can I make this run at server?
javascript:
function confirm_delete()
{
if (confirm("Are you sure you want to delete?")==true)
return true;
else
return false;
}
asp
div.Attributes.Add("onclick", "return confirm_delete();");
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To capture an event at the server side, you need to use
runat="server":The event handler itself needs to be in the code behind. I don’t remember if JScript is supported in ASP.net but
confirmdefinitely isn’t.To have this run on the server, you would want to refactor your application. You would need the
confirm_deletefunction to render the page with a form that confirms their action. This isn’t so bad because you can have it there already just hidden.confirm_deletewould hide the normal content and show the confirmation form. The confirmation form would need to have “OK” or cancel buttons, also hooked to back end event handlers that either execute the deletion (I assume this is where the serverOnClickis already wired) or take you back to the full page view.It’s much more complex than a JavaScript confirm popup but its not too awful to do.