TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Gary King
NA
83
209.2k
Custom Validator not working *** FIXED ***
Sep 29 2011 5:46 AM
I have a form with the following:
- Textbox with RequiredFieldValidator
- 3 x CheckBox with a single CustomValidator
If I try submitting the form without filling in the Textbox, the RequiredFieldValidator works (form is not submitted).
But if I do not tick any of the Checkboxes, the CustomValidator does not prevent the form from being submitted (at least 1 checkbox must be ticked)
ASPX
<
asp
:
CustomValidator
ID
="cvBillType"
runat
="server"
OnServerValidate
="
validateBillType
"
ErrorMessage
="*"
/>
<
asp
:
CheckBox
ID
="chkMB"
runat
="server"
OnCheckedChanged
="chkMB_CheckedChanged"
AutoPostBack
="true"
/>
<
asp
:
CheckBox
ID
="chkCredit"
runat
="server"
OnCheckedChanged
="chkCredit_CheckedChanged"
AutoPostBack
="true"
/>
<
asp
:
CheckBox
ID
="chkCancellation"
runat
="server"
OnCheckedChanged
="chkCancellation_CheckedChanged"
AutoPostBack
="true"/>
.CS
protected
void
validateBillType(
object
source,
ServerValidateEventArgs
args)
{
if
(chkMB.Checked || chkCredit.Checked || chkCancellation.Checked)
args.isValid = true;
else
args.isValid = false'
}
*** SOLUTION ***
I found that the Submit function wasn't checking Page.IsValid and therefore the CustomValidation was not interupting the process.
Reply
Answers (
1
)
Logging remote server with "net use" command
ASP.NET mvc 2 url rewritting or dynamatically create sub domain