Hiya Guys! I have just released a new video!! Check it out! Subscribe please?I have a giveaway in the future and it would help if you subscribed! Thank you guys for your support!
Thanks, this was helpful. I got it to work using a checkboxlist in a wizard.
Follow the above example, set args.isvalid in the ServerValidateEventArgs event. Use a foreach loop to loop through ListItems li in checkboxlist1. Then use an if statement to check if li.Selected is true. If true set args.Isvalid to true.
I just cannot get this to work. I already have a lot of RequiredField validators on my page and they work fine, with the ValildationSummary displaying all of the relevant error messages in one place. But even though I've specified the same ValidationGroup for the CustomValidator the error isn't displayed there. In fact, it won't return an IsValid value of False no matter what I do. Even when my code in the ServerValidate event is simply 'args.IsValid = False'!
@davidmbush I apologise, my question was just 'what am I doing wrong'? All of these controls are within a Wizard control and all of the standard RequiredField validators trigger when I click the 'Next' button, but the CustomValidator just doesn't seem to trigger at the same time. I added a line to report the validity of the checkbox and this doesn't appear until after all of the other validators have been satisfied, and even then it reports 'false' but lets the wizard advance anyway.
@phil2415 I'm going to guess that you don't have an event handler in the wizard to handle the "Next" that will check the "IsValid" property of the page. The other validations are working because they are using javascript. This is a server side validation so it doesn't trigger until you get to the server. You need something to prevent the "Next" from happening if the validations fail.
@davidmbush I do appreciate your help. As per your tutorial I added a 'If IsValid Then' line into the code behind for the next button but the problem is that while this prevents the wizard advancing if any of my RequiredField validators are invalid the CustomValidator doesn't seem to affect the IsValid status of the page itself, since even though the CustomValidator is reporting as 'False' the wizard advances anyway.
@davidmbush Don't apologise, your help is very much appreciated. You put me on the right track and now I've figured it out. The page was 'invalid' but my code to prevent the wizard from advancing if this was the case was wrong. I've now got:
If IsValid = False Then e.Cancel = True
End If
in the NextButtonClick event of the wizard. So now when I click the Next button the RequiredField validators kick in, then the page posts back and the CustomValidator does its thing.
It is useful but i want to know the checkbox when it is bind with listview..
Niyaz27290 1 month ago
This has been flagged as spam show
Hiya Guys! I have just released a new video!! Check it out! Subscribe please?I have a giveaway in the future and it would help if you subscribed! Thank you guys for your support!
hackster2011 3 months ago
good one
kanchangupta19 7 months ago
Thanks, this was helpful. I got it to work using a checkboxlist in a wizard.
Follow the above example, set args.isvalid in the ServerValidateEventArgs event. Use a foreach loop to loop through ListItems li in checkboxlist1. Then use an if statement to check if li.Selected is true. If true set args.Isvalid to true.
devinmccloud 1 year ago
I just cannot get this to work. I already have a lot of RequiredField validators on my page and they work fine, with the ValildationSummary displaying all of the relevant error messages in one place. But even though I've specified the same ValidationGroup for the CustomValidator the error isn't displayed there. In fact, it won't return an IsValid value of False no matter what I do. Even when my code in the ServerValidate event is simply 'args.IsValid = False'!
phil2415 1 year ago
@phil2415 Your question was? I hear your frustration, but no one can help you unless you ask a specific question.
davidmbush 1 year ago
@davidmbush I apologise, my question was just 'what am I doing wrong'? All of these controls are within a Wizard control and all of the standard RequiredField validators trigger when I click the 'Next' button, but the CustomValidator just doesn't seem to trigger at the same time. I added a line to report the validity of the checkbox and this doesn't appear until after all of the other validators have been satisfied, and even then it reports 'false' but lets the wizard advance anyway.
phil2415 1 year ago
@phil2415 I'm going to guess that you don't have an event handler in the wizard to handle the "Next" that will check the "IsValid" property of the page. The other validations are working because they are using javascript. This is a server side validation so it doesn't trigger until you get to the server. You need something to prevent the "Next" from happening if the validations fail.
davidmbush 1 year ago
@davidmbush I do appreciate your help. As per your tutorial I added a 'If IsValid Then' line into the code behind for the next button but the problem is that while this prevents the wizard advancing if any of my RequiredField validators are invalid the CustomValidator doesn't seem to affect the IsValid status of the page itself, since even though the CustomValidator is reporting as 'False' the wizard advances anyway.
phil2415 1 year ago
@phil2415 from here I'd need to see code. Sorry, I can't be of more help on this limited medium
davidmbush 1 year ago
@davidmbush Don't apologise, your help is very much appreciated. You put me on the right track and now I've figured it out. The page was 'invalid' but my code to prevent the wizard from advancing if this was the case was wrong. I've now got:
If IsValid = False Then e.Cancel = True
End If
in the NextButtonClick event of the wizard. So now when I click the Next button the RequiredField validators kick in, then the page posts back and the CustomValidator does its thing.
Thanks again!!
phil2415 1 year ago
great work David. I make similar videos. Lets do something it.
luckyvidoes 1 year ago
Thank you. Very helpful!
jono1978xyz2008 2 years ago
.Net FAIL
Control 'CheckBox27' referenced by the ControlToValidate property of 'CustomValidator1' cannot be validated.
LeperKing 2 years ago
You shouldn't be using the "ControlToValidate" property. It isn't needed and it WILL cause an error if you do. This was covered in the video
davidmbush 2 years ago
great tutorial, thanks
weenoid 2 years ago
Do you have any examples of validating checkboxlists using a custom validator and vb?
tlsonger 2 years ago
thank u so much..great post
imrancsi 2 years ago
Excellent
vklalbeg 2 years ago
Thanks!
Gracias!
from Argentina.
hombresabana 3 years ago
thank you
lasflores147 3 years ago
Thank you very much for the information, but why wouldn't you just use:
args.IsValid = Checkbox1.Checked
Seems much simpler.
Anyway, thanks again.
darnellmoneywilliams 3 years ago
Very nice
thank you!
michelAtPionet 3 years ago