How can I pop up a message box to confirm a delete, from inside a method?
Normally i would just use the following line in my button:
OnClientClick=”return confirm(‘Are you sure you want to delete this comment?’);”
However this delete method can also be called by a querystring, so I need the confirm message box functionality in the method, please?
// delete comment method
private void DeleteComment()
{
int commentid = Int32.Parse(Request.QueryString["c"]);
// call our delete method
DB.DeleteComment(commentid);
}
I can’t click the button through code, because it doesn’t fire the OnClientClick event
btnDelete_Click(null, null);
Regards
Melt
I would recommend doing something like this.
Add a 2nd query string argument to dictate if it is confirmed or not. Definitely add some code to confirm that the user is logged in so that this query string methodology doesn’t get hit by a webcrawler or something and accidentally delete all your comments.