I am a Frontenddeveloper without further knowledge of C#, so please excuse my maybe stupid question. I am currently trying to use jQuery UI Dialog to replace the common JavaScript alert() and confirm() boxes. This is working good so far in the Frontend but now I found this snippet in one of the C# pages and I don't know what's the best way to switch this from confirm() to jQuery dialog(). Any ideas?
string delCode = "javascript:"
+ "if ( confirm(\'Are you sure you wish to delete this?\')){ "
+ this.Page.ClientScript.GetPostBackEventReference(this, string.Empty)
+ ";} else { return false; }";
EDIT: After playing around a bit more I found out, that it will not work without adding an OnClientClick Attribute to prevent the Postback when clicking the button. How do I add this Attribute from within the Code behind? btnDelete.Attributes.Add("OnClientClick","foo"); does not work for me. What's the right way to solve this?
Here ist what I want to have, it's just simple JS so far (you see the C# snippet for the Button as a comment above the HTML content in the Fiddle): https://jsfiddle.net/SchweizerSchoggi/xts01hrx/16/
this.Page.ClientScript.GetPostBackEventReference(this, string.Empty)in javascript variable and do same thing you did elsewhere