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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:21:03+00:00 2026-06-01T12:21:03+00:00

I am using a WebForms GridView control. When a user clicks Update on a

  • 0

I am using a WebForms GridView control. When a user clicks “Update” on a row, I want to check the values they entered against some other records.

From that, if I return true, I’d like to display a confirm dialog asking the user if they’d like to continue with their update.

A javascript confirm dialog probably won’t work because I don’t always want to show this dialog, only when the values entered meet a certain condition.

Any suggestions?

  • 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-01T12:21:05+00:00Added an answer on June 1, 2026 at 12:21 pm

    I would suggest using the RowDataBound event to check for those conditions and add the confirmation dialog where needed.

    EDIT : Compare dates and show a confirmation if they’re different

    See this jsFiddle for a demonstration.

    <script type="text/javascript">        
       validateInput = function(inputDate, compareDate, confirmButtonID) {           
           var confirmButton = document.getElementById(confirmButtonID);       
           if (confirmButton) {               
               $(confirmButton).one("click", function() {
                   var result = dates.compare(inputDate, compareDate);
                   if (result != 0){ //change to suit your needs
                       return confirm("Are you sure you want to save these changes?");        
                   }
                   return true;
               });                                                                                 
           }
        }             
    </script>
    

    And here’s the code for the dates class used for the comparison (link):

    <script type="text/javascript">
        var dates = {
            convert:function(d) {
                return (
                    d.constructor === Date ? d :
                    d.constructor === Array ? new Date(d[0],d[1],d[2]) :
                    d.constructor === Number ? new Date(d) :
                    d.constructor === String ? new Date(d) :
                    typeof d === "object" ? new Date(d.year,d.month,d.date) :
                    NaN
                );
            },
            compare:function(a,b) {
                return (
                    isFinite(a=this.convert(a).valueOf()) &&
                    isFinite(b=this.convert(b).valueOf()) ?
                    (a>b)-(a<b) :
                    NaN
                );
            },
            inRange:function(d,start,end) {
               return (
                    isFinite(d=this.convert(d).valueOf()) &&
                    isFinite(start=this.convert(start).valueOf()) &&
                    isFinite(end=this.convert(end).valueOf()) ?
                    start <= d && d <= end :
                    NaN
                );
            }
        }
    </script>
    

    In the RowDataBound event of the GridView, assign the onchange function for each row:

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        var inputCtrl = e.Row.FindControl("txtEnteredDate") as TextBox;
        if (inputCtrl != null)
        {
            var updateButtonCtrl = e.Row.FindControl("btnUpdate") as Button;
            if (updateButtonCtrl != null)
            {
                inputCtrl.Attributes["onchange"] = string.Format("return validateInput(this.value, '{0}', '{1}');", DataBinder.Eval("DateToCompare"), updateButtonCtrl.ClientID);
            }
        }
    }    
    

    jQuery Confirmation Dialog

    If you need something more flexible than a regular JavaScript confirm dialog, you can change the above to use the jQuery UI Dialog as a confirmation instead.

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

Sidebar

Related Questions

Im using asp.net webforms. c# I want to validate a form. In the codebehind
I'm using ASP.NET WebForms. I'm using the standard sitemap provider. Home > User >
I am having an issues while using the <asp:login> tag. When a user clicks
I'm using WebForms MVP to create some simple reporting applications. Most of these applications
when I tried to update my gridview which is connected using <asp:LinqDataSource> and Enabling
I want to print the values on crystal report that user input on the
I'm using webforms ASP.NET, with masterpages. I want to add a LANG attribute to
We develop asp.net webforms using visual studio 2008. For multilingual support, we translate all
When using ASP.net webforms my usual solution would have following type of setup -
I'm using C# and WebForms and running into an issue. I have a class

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.