Confirm delete of record, from method

Posted by Melt on Stack Overflow See other posts from Stack Overflow or by Melt
Published on 2010-06-08T16:25:10Z Indexed on 2010/06/08 16:32 UTC
Read the original article Hit count: 253

Filed under:

Hi all,

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

© Stack Overflow or respective owner

Related posts about ASP.NET