Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

modal popup show quit working..

$
0
0

in order to display a bulleted list of validation errors on a modal popup I go through a validation method before inserting a record into SQL Server. When you hit the save button it goes through a series of validation checks and if any fail it returns a false to the Save method. If that is the case, the save routine does an mpe_new.Show() - and skips the save.During the validation run it also inserts items to a bulleted list to indicate which fields need correction. This worked for a while and then  it quit - it does not insert the record,but the modal popup closes - apparently ignoring the Show(). Odd thing is if you try to insert another record the validation errors are displayed?

StringCollection strcol = new StringCollection();
        BulletedList BulletedList1 = (BulletedList)pnlnew.FindControl("BulletedList1");

        strcol.Add("Distance is required!"); //0
        strcol.Add("Distance must be a number"); //1
        strcol.Add("Hours cannot be less than 1 or more than 23."); //2
        strcol.Add("Minutes cannot be less than 1 or more than 59."); //3
        strcol.Add("Total Hours and Total minutes are both blank. At least one must have a value."); //4
        strcol.Add("Total Hours must be a number."); //5
        strcol.Add("Total Minutes must be a number."); //6
        strcol.Add("Temp must be a whole number."); //7
        strcol.Add("Rides cannot be future dated!"); //8
        strcol.Add("Ride Hours must be a number."); //9
        strcol.Add("Ride Minutes must be a number.");//10
        strcol.Add("Low temp cannot be higher than high temp");//11
        strcol.Add("Ride time cannot be greater than total time.");//12
        strcol.Add("You  have selected the multi-day option - there must be at least one day entered."); //13
        strcol.Add("Number of days must be a number.");//14
        strcol.Add("Multiday Hours must be a number.");//15
        strcol.Add("Multiday Minutes must be a number.");//16
        bool isvalid = true;
        BulletedList1.Items.Clear();

        DateTime dt = Convert.ToDateTime(tbridedate.Text);
        if(dt > DateTime.Today )
        {
            isvalid = false;
            BulletedList1.Items.Add(strcol[8]);
        }

this is the validation/ It runs through alot of these and if isvalid = false it sends a false back to the calling method.

protected void btnsave_Click(object sender, EventArgs e)
    {
        bool isvalid;
        isvalid = validateForm();
        if (isvalid == false)
        {
            mpe_new.Show();
        }

        else
        {
            //read all the values and insert to SQL...
         }
}

If you provide valid data it does the insert properly.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>