asp.net validation
-
hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
I have just been working on a similar problem. What I have done is to disable all the RFV and when I submit (there is another condition as well) I loop through the RFVs on the form, enable them and call validate on them. This seems to work OK for my environment. I disable them all again on cancel.
-
I have just been working on a similar problem. What I have done is to disable all the RFV and when I submit (there is another condition as well) I loop through the RFVs on the form, enable them and call validate on them. This seems to work OK for my environment. I disable them all again on cancel.
but the event is fired before the cancel code is processed! that means the before the control goes in the code for the cancel button, the validator is alredy fired! so back to square 1!:( "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
Unless your skip button does more than just redirect the user to the next page then make it a simple html control rather than an ASP.NET server control. Otherwise you might be able use a compare validator rather than a required field validator
-
Unless your skip button does more than just redirect the user to the next page then make it a simple html control rather than an ASP.NET server control. Otherwise you might be able use a compare validator rather than a required field validator
is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
is there any way i can make some controls skip some validation but process others??? like can i make a button invalidate two validation(RFV and CV) and skip CompareValidator?? i.e when the RequiredFieldValidator or the CustomValidor is voilated the button knows and gives error.. but when the CompareValidator is voilated the button does not do anything, instead another button does somethin... can it be done? tks,.,. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
The best way to handle this is to check in the handlers for the buttons. Do you checks and validation then enable or disable the validators as needed.
OnSumit(...) { if( field1 != whatever ) { RFV.Enabled = true; Page.IsValid = false; return; } }
-
The best way to handle this is to check in the handlers for the buttons. Do you checks and validation then enable or disable the validators as needed.
OnSumit(...) { if( field1 != whatever ) { RFV.Enabled = true; Page.IsValid = false; return; } }
if i doi as you say...then it defeats the purpose of validataion doesn't it?? if i am already checking the validation myself if(field!= whatever) then why bother to use validation? might as well check myself right? pls do correct me if i am wrong... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
if i doi as you say...then it defeats the purpose of validataion doesn't it?? if i am already checking the validation myself if(field!= whatever) then why bother to use validation? might as well check myself right? pls do correct me if i am wrong... "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
You're pretty much asking to go beyond the normal usage of validators anyway.:rolleyes:
-
You're pretty much asking to go beyond the normal usage of validators anyway.:rolleyes:
so would you say.. i shouldn't use validator at all and do my validation myself? "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
-
hi,, i am using asp.net validation using ReqiredFieldValidator but there is one problem i am facing... there are two buttons lets say submit and skip.. if the user DOES NOT enter a name and clicks "GO" then the RFV should fire and tell him there is an error... but if the user does not want to enter his name he can click skip and the RFV shouldn't fire.. but in my case.. the RFV fire in both event. is there any way i can restrict the firing of the RFV only when "Go" is presses and not skip?? can sonmeone pls gimme some advice... tks.. "Rejoice always, pray without ceasing, in everything give thanks; for this is the will of God in Christ Jesus for you."1Thess. 5:16-18
set the skip button CauseValidation=false :eek: I try my best!