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 7666591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:52:20+00:00 2026-05-31T14:52:20+00:00

I use checkbox control in gridview i want to show confirm before checkboxchanged event.

  • 0

I use checkbox control in gridview i want to show confirm before checkboxchanged event.

Confirm box is asking question but not postback it, doing nothing…

// CS

        TemplateField field = new TemplateField(){
            HeaderText = "AKTIF",
            ItemTemplate = new AddTemplateToGridView("AKTIF")
        };
        field.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
        field.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
        field.ItemStyle.Width = Unit.Pixel(40);
        newXGrid.Columns.Add(field);

// ITEMPLATE

        public class AddTemplateToGridView : ITemplate
        {
            String columnName;

            public AddTemplateToGridView(String colname)
            {
                columnName = colname;
            }

            void ITemplate.InstantiateIn(System.Web.UI.Control container)
            {
                if (columnName == "AKTIF")
                {
                    CheckBox chk = new CheckBox() { ID="chkAktif", AutoPostBack=true };
                    chk.Attributes.Add("onclick","return confirm('Are you sure ?')");
                    chk.CheckedChanged += new EventHandler(l_CheckedChanged);
                    container.Controls.Add(chk);
                }
            }


            void l_CheckedChanged(object sender, EventArgs e)
            {
               ...
            }



        }

// My checkbox on page

<input id="ctl00_MainContent_ctl11_ctl02_chkAktif" type="checkbox" name="ctl00$MainContent$ctl11$ctl02$chkAktif" onclick="return confirm('Are you sure ?');setTimeout('__doPostBack(\'ctl00$MainContent$ctl11$ctl02$chkAktif\',\'\')', 0)">
  • 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-31T14:52:21+00:00Added an answer on May 31, 2026 at 2:52 pm

    Change this:

    chk.Attributes.Add("onclick","return confirm('Are you sure ?')");
    

    to this:

    chk.Attributes.Add("onclick","if (!confirm('Are you sure ?')) return false;");
    

    Set AutoPostBack="true" for the Checkbox to trigger the postback on click.

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

Sidebar

Related Questions

The documentation says to use: $(input[type='checkbox']).bind( change, function(event, ui) { But I want to
Why can't the data in mysql not updated when I use checkbox, I already
I have a checkbox in GridViewColumn which i use for show/change database value. The
I use the following HTML helper to generate check box: <%= Html.CheckBox(DeluxeFeature)%> Now I
I am trying to use the server control for an asp checkbox: <asp:CheckBox ID=generalInformation
I have been playing around with the WPF GridView control (DesktopUI not Silverlight) and
I have an asp:checkbox control, and I want to change the visibility of a
In my simple WPF application I use regular CheckBox control. It looks like I
Instead of using a CheckBoxList helper control I want to use the editor templates
I Use a CheckBox in Header of Column and that coulmn is Container Cehckboxes

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.