Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesAdd a confirmation to delete button in a gridAdd a confirmation to delete button in a grid
Previous
 
Next
New Post
2/2/2013 8:36 AM
 

Richard,

thanks again for the reply. Your theory about the update panel is true, I could resolve this by adding a postback trigger in the grid's ItemCreated event.

I also could make the dnnConfirm function work, but now, the name is missing again :-( It was there with the alert function. Here is the code:

$(function () {
$(".confirmingGrid .DeleteButton")
.dnnConfirm({
   text: "Hit me. My name is " + $("td:eq(4)", $(this).parents("tr")).text(),
   yesText: "Yes",
   noText: "No",
   title: "Please confirm",
   dialogClass: "dnnFormPopup",
   isButton: true});
});

Any idea?

Best wishes
Michael


Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
New Post
2/2/2013 12:05 PM
 

Hi Michael,

To make it work with the UpdatePanel we need to attach to an MS specific event.

The name is not working for you because you are attaching the same confirmation to every button ie with the same text.  The expression for that text does not work because it evaluates once up front.  It's not evaluated against the context of the button.  Try this...

 (How do you get your text to format pretty?)

jQuery(function () {
Sys.Application.add_load(function () {
jQuery(".confirmingGrid .DeleteButton")
.unbind("click")
.bind("click", function () {
$(this).dnnConfirm({
text: $("td:eq(1)", $(this).parents("tr")).text()
// add the other stuff dnnConfirm wants here...
});
})
;
});
});


Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
2/2/2013 12:12 PM
 

I have not tested these scenarios but:

  • I think this should work correctly in the presence of UpdatePanels (including unrelated ones).
  • I also think it will work if the same module is used twice on the page therefore including the script twice.

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
2/2/2013 12:16 PM
 
It crosses my mind that this may not meet your original requirement. My script displays the name only because the name is already in the grid. If you rely on data that is only available at the server then you will need another way to smuggle it to the clirnt.

For that, it might be better to stick to your original plan!

Best wishes,
- Richard
Agile Development Consultant, Practitioner, and Trainer
www.dynamisys.co.uk
 
New Post
2/3/2013 4:50 AM
 

Richard,

thak you very much for your help - I really appreciate it. We're close to the sulution, I think, ít works fine except a small little problem - the confirm dialog appears on the second click on the button... Here is the grid:

and here is the confirm Dialog when I click the delete icon in the first row (twice):

Confirm Message

Here is what I did:

1) In the grid's ItemCreated event, I added a postback trigger to the delete button:

protected void KeyResourcesGrid_ItemCreated(object sender, DataGridItemEventArgs e)
{
   if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
   {
      ImageButton deleteButton = (ImageButton)e.Item.FindControl("DeleteButton");
      if ((AJAX.IsEnabled()) && (deleteButton != null))
         AJAX.GetScriptManager(base.Page).RegisterPostBackControl(deleteButton);
   }
}

2) Then I injected this script in the Page_Init event:

$(function () {
   $(".confirmingGrid .DeleteButton").click(function(e) {
      e.preventDefault();
      $(this).dnnConfirm({
         text: "Are you sure you want to delete \"" + $("td:eq(5)", $(this).parents("tr")).text() + "\"?",
         yesText: "Yes",
         noText: "No",
         title: "Confirm",
         dialogClass: "dnnFormPopup",
         isButton: true
      });
   });
});

The problem is - as I mentioned - that the confirm message only appears on the second click (also if I click some other delete buttons between the first and the second click).

Any idea?

Best wishes
Michael

 


Michael Tobisch
DNN★MVP

dnn-Connect.org - The most vibrant community around the DNN-platform
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesAdd a confirmation to delete button in a gridAdd a confirmation to delete button in a grid


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out