0

I have an ascx control that inherits from ValidatableUserControl.

I have several requiredfieldvalidators on the page, and all of them are getting fired except the one inside an asp:panel

This code is inside a <table>

<asp:Panel runat = "server" ID = "PurchaseOrderPanel">
                <tr>
                  <td><div  class="txtClass">
                  <span class="required">*</span>
                  Number:
                  </div>
                  </td>
                  <td>
                  <asp:textbox  CssClass = "txtClass" size="47" runat="server" id="Number" ></asp:textbox>
                   <asp:requiredfieldvalidator id="NumberRequired" runat="server" controltovalidate="Number" errormessage="Number is a required field" >*</asp:requiredfieldvalidator>
                  </td>
                 </tr>
              </asp:Panel>

If I move the requiredfieldvalidator outside of the asp:panel, it would work, but that breaks the formatting.

The codebehind also uses

public override string ValidationGroup {
set {
base.ValidationGroup = value;
FirstNameRequired.ValidationGroup = LastNameRequired.ValidationGroup
= telPhone.ValidationGroup = value;
}
}

However, the controls other than firstname, lastname and telphone are properly being fired too, and none of those have any validation group attached to them.

(Note: the code is not entirely written by me, I am just trying to add the asp:panel control to someone else's code)

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by dnanetwork
0

I just made it work by adding NumberRequired.ValidationGroup in that snippet from codebehind that I posted but I am still confused why I had to add that while other controls were working just fine... hmm!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.