Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:25:01+00:00 2026-06-05T14:25:01+00:00

I’m trying to get a jQuery-UI confirmation dialog to work when clicking a LinkButton

  • 0

I’m trying to get a jQuery-UI confirmation dialog to work when clicking a LinkButton in a DataList control, but nothing I’ve tried seems to work. The DataList is a list of file attachments to a database entry.

Here’s the relevant section of the original .aspx file:

<ul id="attachmentList">
  <asp:DataList ID="dlAttachments" runat="server" DataKeyField="AttachID" RepeatLayout="Flow">
    <ItemTemplate>
      <li>
        <asp:HyperLink ID="hlViewAttach" runat="server" NavigateUrl='<%# CreateAttachURL(Convert.ToInt32(Eval("AttachID"))) %>'
          Text='<%# Eval("Description").ToString() %>' Target="_blank" />
        <em>(</em><asp:Label ID="lblType" runat="server" Text='<%# GetFriendlyFileType(Eval("FileType").ToString()) %>' Font-Italic="True"></asp:Label>,
        <asp:Label ID="lblSize" runat="server" Text='<%# GetFriendlyFileSize(Convert.ToInt32(Eval("FileSize"))) %>' Font-Italic="True"></asp:Label><em>)</em>
        <asp:LinkButton ID="btnDelAttach" runat="server" OnClick="btnDelAttach_Click"
          OnClientClick="return ConfirmDeleteAttachment(this, 'Please confirm deletion', 'Are you sure you wish to delete this attachment?');">DELETE</asp:LinkButton>
      </ItemTemplate>
    </asp:DataList>
  </ul>

Here’s the HTML for the above as generated by ASP.Net:

<ul id="attachmentList">
<span id="ctl00_mainContent_wizNewIPR_dlAttachments">
  <li><a id="ctl00_mainContent_wizNewIPR_dlAttachments_ctl00_hlViewAttach" href="ViewAttachment.aspx?AttachID=260" target="_blank">Attachment description #1</a>
    <em>(</em><span id="ctl00_mainContent_wizNewIPR_dlAttachments_ctl00_lblType" style="font-style:italic;">Acrobat PDF document</span>,
    <span id="ctl00_mainContent_wizNewIPR_dlAttachments_ctl00_lblSize" style="font-style:italic;">74.61 kB</span><em>)</em>
    <a onclick="return ConfirmDeleteAttachment(this, 'Please confirm deletion', 'Are you sure you wish to delete this attachment?');"
      id="ctl00_mainContent_wizNewIPR_dlAttachments_ctl00_btnDelAttach" href="javascript:__doPostBack('ctl00$mainContent$wizNewIPR$dlAttachments$ctl00$btnDelAttach','')">DELETE</a></li>
</span>
</ul>

The jQuery function I’m using is a simple Yes/No dialog box to confirm deletion of the attachment. Here’s the Javascript source:

//Confirm Delete Attachment dialog
var delConfirmed = false;
function ConfirmDeleteDialog(obj, title, dialogText) {
  if (!delConfirmed) {
    //add the dialog div to the page
    $('body').append(String.Format("<div id='confirmDeleteDialog' title='{0}'><p>{1}</p></div>", title, dialogText));
    //create the dialog
    $('#confirmDeleteDialog').dialog({
      modal: true,
      resizable: false,
      draggable: false,
      close: function(event, ui) { $('body').find('#confirmDeleteDialog').remove(); },
      buttons:
        {
          'Yes, delete it': function() {
            $(this).dialog('close');
            delConfirmed = true;
            if (obj) obj.click();
          },
          'No, keep it': function() {
            $(this).dialog('close');
          }
        }
      });
    }

    return delConfirmed;
}

I got this from http://markmintoff.com/2011/03/asp-net-jquery-confirm-dialog/ – it looks pretty simple and makes sense, but for some reason it isn’t working for me. I never get the jQuery-UI confirmation dialog, it just triggers my button’s OnClick event when I click the button.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:25:04+00:00Added an answer on June 5, 2026 at 2:25 pm

    The answer was to make the function call in the OnClientClick event of the LinkButton (“ConfirmDeleteAttachment”) match the name of the function I was calling! This was just a stupid typo.

    Credit for this answer goes to the developer (Mark Mintoff, see his blog at http://markmintoff.com) whose code I used — I emailed him and he pointed out my mistake.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.