Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > CustomValidator server-side

Reply
Thread Tools

CustomValidator server-side

 
 
Next
Guest
Posts: n/a
 
      01-06-2004
Hi,

I want to use the CustomValidator control as follows:

<asp:label id="LabelQuantity" runat="server" ToolTip="Enter a quantity
greater than or equal to the minimum order"
Font-Bold="True">Quantity</asp:label>
<asp:requiredfieldvalidator id="RequiredFieldValidatorQuantity"
runat="server" ControlToValidate="Quantity" ErrorMessage="Required Field"
Display="Dynamic">Required</asp:requiredfieldvalidator>
<asp:CompareValidator id="CompareValidatorQuantityInt"
Operator="DataTypeCheck" Type="Integer" runat="server"
ControlToValidate="Quantity" ErrorMessage="Enter whole number"
Display="Dynamic">Enter whole number</asp:CompareValidator>
<asp:CompareValidator id="CompareValidatorQuantityPos"
Operator="GreaterThan" Type="Integer" ValueToCompare="0" runat="server"
ControlToValidate="Quantity" ErrorMessage="Enter positive number"
Display="Dynamic">Enter positive number</asp:CompareValidator>
<asp:CustomValidator id=CustomValidatorQuantity runat="server"
Display="Dynamic" ErrorMessage="Invalid Increment"
ControlToValidate="Quantity" ClientValidationFunction="CheckQuantity"
OnServerValidate="QuantityIncrementCheck">Invalid
Increment</asp:CustomValidator>

However I get this error if and include the OnServerValidate attribute:

"External component has thrown an exception."

If I exclude the OnServerValidate attribute the page works just fine. Why
would this attribute cause such an error?
Any help or suggestions would be appreciated.
I don't even know where to begin to debug this kind of error. Page breaks in
the Page OnInit() don't work.

------Client-Side:---------------
function CheckQuantity(sender, args)
{
var increments =
document.getElementById("MinimumQuantityIncrement" ).innerHTML;
increments = parseInt(increments.split(" ")[0]);

var qty = parseInt(args.Value);
if (qty % increments == 0) { args.IsValid = true; }
else { args.IsValid = false; }
}

-------Server-Side:--------------
private void QuantityIncrementCheck(object sender, ServerValidateEventArgs
args)
{
try
{
int qtyIncrement = 0;//minimumQuantityIncrement;
int qty = int.Parse(args.Value);

args.IsValid = ((qty % qtyIncrement) == 0);
}
catch
{
args.IsValid = false;
}
}

Thanks in advance,
Aaron


 
Reply With Quote
 
 
 
 
Next
Guest
Posts: n/a
 
      01-06-2004
Changed the method from private to protected and fixed the problem.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
CustomValidator Delima OR Rendering the WebUIValidation Tag Art Kedroski ASP .Net 0 07-25-2003 11:25 PM
CustomValidator bug? George Ter-Saakov ASP .Net 2 07-22-2003 02:33 PM
CustomValidator controls George Ter-Saakov ASP .Net 0 07-21-2003 09:42 PM
CustomValidator limitation? Wayne MJ ASP .Net 0 07-21-2003 01:51 AM
Errormessage in CustomValidator Edmilson ASP .Net 0 07-10-2003 12:56 PM



Advertisments