Richard Howells wrote:
So what did you actually try?
Richard,
thanks for your interest.
Well, first I tried some stuff that looked like the other thing, but it did not work.
I then tried to assign a common error message. I assigned CssClass="confirm" to all of the buttons and injected a script in the Page_Init event like
StringBuilder script = new StringBuilder();
script.Append("jQuery(function($) { $('.confirm').dnnConfirm( { text: '");
script.Append(Localization.GetSring("DeleteItem.Text"));
script.Append("', yesText: '");
script.Append(Localization.GetSring("Yes.Text"));
script.Append("', noText: '");
script.Append(Localization.GetSring("No.Text"));
script.Append("', title: '");
script.Append(Localization.GetString("Confirm.Text");
script.Append("', dialogClass: 'dnnFormPopup', isButton: true });})");
if (!(base.ClientScript.IsClientScriptBlockRegistered("ConfirmDeleteScript")))
base.ClientScript.RegisterClientScriptBlock(this.GetType(), "ConfirmDeleteScript", script.ToString(), true);
That worked fine.
Then I commented this out and went back to the Grid_ItemDataBound Event. There I did something like this:
ImageButton delBtn = (ImageButton)e.Item.FindControl("DeleteBtn");
StringBuilder script = new StringBuilder();
script.Append("jQuery(function($) { $().dnnConfirm( { text: '");
script.Append(String.Format(Localization.GetSring("ConfirmDelete.Text", base.LocalResourceFile), ((DateRowView)e.Item.DataItem)["Name"]));
script.Append("', yesText: '");
script.Append(Localization.GetSring("Yes.Text"));
script.Append("', noText: '");
script.Append(Localization.GetSring("No.Text"));
script.Append("', title: '");
script.Append(Localization.GetString("Confirm.Text");
script.Append("', dialogClass: 'dnnFormPopup', isButton: true });})");
delBtn.OnClientClick = script.ToString();
When I click to that, I run into an error. The script looks fine except that all the single quotes are HTML-encoded and therefore the script is unusable. No confirm dialog, the item gets deleted as the program execution is continued.
Any idea?
Best wishes
Michael