N
Next
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
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