Sharepoint Forum

Ask Question   UnAnswered
Home » Forum » Sharepoint       RSS Feeds

Popup dialog on item delete in a List

  Asked By: Harshini    Date: Oct 29    Category: Sharepoint    Views: 4321

I have created a custom webpart that looks very much like a SharePoint
list. If you select the "Delete Item" from a SharePoint List then
there is a pop-up dialog that appears asking the user to confirm the
delete. How can I do this?



3 Answers Found

Answer #1    Answered By: Candi Branch     Answered On: Oct 29

I would guess that you're going to have to get down and dirty with the
client-side code. You'll need to use a javascript confirm  dialog, so the
onclick event handler of the delete  button would look something like this:

onclick="return checkDelete()"

...and the Javascript function behind it would be fairly simple:

function checkDelete() {
if(confirm("Are you sure you want to delete this item?")) {
return true;
else {
return false;

Answer #2    Answered By: Jan Chen     Answered On: Oct 29

No sure if I can make that work - you see the "Delete Item" button is really
a Hyperlink - my toolbar is built just like the toolbar is in any
out-of-the-box webpart  using:

////----- toolbar
tlb =
tlb.ID = "NavNodesTB";
// create the buttons template for the toolbar
BtnTemplate btnTemplate = new BtnTemplate();
btnTemplate.PopulateButtonSet(btnInfo, EventLogname);
// assign the btnTemplate to the toolbar
tlb.Template_Buttons = btnTemplate;
The BtnTemplate class contains the Hyperlink.

Answer #3    Answered By: Britni Shepard     Answered On: Oct 29

There's certainly a way to make it work with a Hyperlink as well; can I
get some more information on the BtnTemplate class? That's where the magic
will need to happen.
Generally it'll be something like

myHyperLink.Attributes.Add("onclick", "return checkDelete()");

...but I'd have to check the client-side rendered markup to be sure of what
it's doing.

Didn't find what you were looking for? Find more on Popup dialog on item delete in a List Or get search suggestion and latest updates.