Validation summary message box does not pop-up for a required field validator

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • user1980
    New Member
    • Dec 2009
    • 112

    Validation summary message box does not pop-up for a required field validator

    hello

    i am working on web-form for which I have set the validation summary showmessagebox = "true".
    I have two required field validators, which trigger on a checkbox's OnCheckedChange d event....now my problem is, when I hit submit, the page does not submit if I do not enter any values in the text boxes..which is correct behavior but it does not point out to the error or does not display the message box...i have to scroll up to see what is wrong with he page and then try to enter the values...I do not understand why my message box does not show up or at least why my setfocusonerror which is set to true does not show me the text boxes...

    please find my code below...
    Code:
    <asp:CheckBox ID="wghtGPA" runat="server" AutoPostBack="true" OnCheckedChanged="wghtGPA_CheckedChanged" />
    Code:
    <asp:RequiredFieldValidator ID="rqrd_gpa" runat="server"  ControlToValidate="gpa" Display="Dynamic"  Enabled="false"  ErrorMessage="Please enter the GPA"  SetFocusOnError="true" ValidationGroup="Submit"></asp:RequiredFieldValidator>
    
     <asp:RequiredFieldValidator ID="rqrd_classgpa" runat="server" Enabled="false" Display="Dynamic" ControlToValidate="classgpa" ErrorMessage="Please enter the GPA in the class" SetFocusOnError="true" ValidationGroup="Submit"></asp:RequiredFieldValidator
    Code:
    protected void weightedGPA_CheckedChanged(object sender, EventArgs e)
            {
                SetFocus(gpa);
                if (weightedGPA.Checked == true)
                {
    
                    required_gpa.Enabled = true;
                  //  required_gpa.SetFocusOnError = true;
                    required_classgpa.Enabled = true;
                   // required_classgpa.SetFocusOnError = true;
    
                }
                else
                {
                    required_gpa.Enabled = false;
                    required_classgpa.Enabled = false;
    
                }
                SetFocus(gpa);
    
            }
    thank you
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Well your "message box" (I which I don't see in your posted code) is not going to shown to the user if you are displaying it in your C#-server-code.

    You should be using a JavaScript alert()...which displays a "message box" in the web browser.

    You will have to do this client side when you validate the page.

    -Frinny

    Comment

    Working...