1

I am using ASP.NET 1.1 and I'm having problems with my validationsummary and validationcontrols working. On button click, required field validations, etc are not fired. How do I fix this?

Here's the code:

<asp:ValidationSummary id="EsppDataInputValidationSummary" runat="server" Font-Names="Arial" Font-Size="8pt" HeaderText="Please Correct the following error(s):" DisplayMode="List" ShowSummary="True"></asp:ValidationSummary></TD>

<asp:RequiredFieldValidator id="Validator1" runat="server" Font-Size="8pt" Font-Names="Arial"
ControlToValidate="txtPrice" Display="None" ErrorMessage="Please enter the Price"></asp:RequiredFieldValidator>

<asp:textbox onblur="return ValidateLength(this)" style="Z-INDEX: 0; TEXT-ALIGN: right" id="txtPurchasePrice" onkeypress="return IsValidChar(event);" onkeyup="return ValidateLength(this)" runat="server" Width="160px" MaxLength="10"></asp:textbox>

<asp:button id="btnAdd" runat="server" Text="Add"></asp:button>"
user2545231
  • 245
  • 3
  • 10

1 Answers1

1

I think the problem may be you're not testing the Page.IsValid property in you codebehind, but as you don't show it I couldn't be sure. You need to test it before doing anything, else your form will be submitted and you'll never get to actually see your validation summary...

So, in your onClick event handler, where you do all your stuff for now I presume :

if(Page.IsValid)
{
//do the actions you wish here
}
Laurent S.
  • 6,816
  • 2
  • 28
  • 40
  • another thing is, the button should only fire up 'Validator1' and not all validations in the page. – user2545231 Jul 03 '13 at 13:47
  • That's another problem. It's been a long time since I haven't done any 1.1, but I don't think this is possible in this version of the Framework, hence the introduction of ValidationGroups in further releases of the Framework. Have you tried with my code up here to see if you could already get you validation summary to show ? – Laurent S. Jul 03 '13 at 13:51