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

  • SEARCH
  • Home
  • 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 6653889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:19:29+00:00 2026-05-26T01:19:29+00:00

I have looked around for a way of implementing this. Here is a pseudocode

  • 0

I have looked around for a way of implementing this. Here is a pseudocode representation of what I have:

bool hasData = ItemHasData(itemid);
Confirm = "false"; // hidden variable

if (hasData)
{
    //Code to call confirm(message) returns "true" or "false"
    if (Confirm == "true")
    {
         //Delete item
    }
    else if (Confirm == "false")
    {
         return;
    }
}

The code to call confirm uses a asp:Literal control and sets it equal to the confirm. I can get the popup but only after the function exits. And it does nothing with the conditions after that.

The general consensus seems to be that calling the javascript at that specific line is impossible (makes sense due to the server side/client side gap), but how can I achieve this? I tried using the ConfirmButtonExtender from the ASP.NET AJAX Toolkit but I couldn’t interact with the confirmbuttonextender object from the code behind when the object is set to runat=”server”.

edit:

Sorry, I did miss those tidbits. Thanks Icarus.

The control itself is the GridView (the pseudo version is actually from the gvData_RowCommand function)’s rowcommand. The first check looks to see if the CommandName is DeleteItem and if so goes into this.

The gvData’s columns are set based off a list of headers (and the dataset) passed as the table it is working against is for multiple items with different required information. The gvData’s data is there, I just need to get a Yes/No (or in reality it’ll end up being Ok/Cancel) dialog to verify they want to delete the item when there is data.

  • 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-05-26T01:19:30+00:00Added an answer on May 26, 2026 at 1:19 am

    One method I end up using in some situations is to have a Panel that displays the Confirm / Cancel buttons. This avoids the need to handle JavaScript events and uses ASP.NET entirely.

    <asp:Panel ID="pDeleteConfirm" runat="server"
        CssClass="AlertDialog"
        Visible="False">
        <p>Do you wish to delete the selected record?<br />
        <asp:Button ID="btDeleteYes" runat="server" OnClick="btDelete_Click" Text="Delete" />
        <asp:Button ID="btDeleteNo" runat="server" OnClick="btDelete_Click" Text="Cancel" />
        </p>
    </asp:Panel>
    
    <asp:GridView ID="gvData" runat="server"
        AutoGenerateColumns="False" 
        CssClass="GridView"
        DataKeyNames="ID"
        DataSourceID="sqlData"
        EmptyDataText="There is no data entered in the system."
        OnRowDeleting="gvData_RowDeleting">
        ......
    </asp:GridView>
    

    I use the OnRowDeleting event to show the Panel

    protected void gvData_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        // Show confirmation dialog
        pDeleteConfirm.Visible = true;
    
        // Select the row to delete
        gvData.SelectedIndex = e.RowIndex;
    
        // Cancel the delete so the user can use the confirm box
        e.Cancel = true;
    }
    

    Handle the button Click events

    protected void btDelete_Click(object sender, EventArgs e)
    {
        Button bt = (Button)sender;
        switch (bt.ID)
        {
            case "btDeleteYes": // they confirmed a delete
                sqlData.Delete();
                break;
    
            case "btDeleteNo": // they clicked cancel
                // Do nothing
                break;
    
            default:
                throw new Exception("Unknow button click in btDelete_Click");
        }
        // clear selection and hide the confirm box
        gvData.SelectedIndex = -1;
        pDeleteConfirm.Visible = false;
    }
    

    This isn’t JavaScript but you can add in some UpdatePanels to do AJAX work on it.

    Just one method to do it through ASP.NET rather than JavaScript handling.

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

Sidebar

Related Questions

Sorry if this is obvious but have looked around and can't get this working:
I have looked around and i wast able to find a way so sort
I have looked around SO for similar questions, but it seems that this has
I've gone around and looked for this solution for forever, here is my problem:
I have looked around on the Internet trying to answer this question. It seems
So I have looked around and saw a few posts on similar things but
I have looked all around and only found solutions for python 2.6 and earlier,
Looked around SO but couldn't find anything useful, so.. I have a Backbone.js contacts
Have looked quite hard for this answer but having no luck. I have 3
Is there some way I can make an Extension Method asynchronous? I have looked

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.