More than a ASP:Wizard control - c#

How can one have more than a Wizard control on the same page without the "RequiredFieldValidator" will affect the other Wizard control?

Set the ValidationGroup property on all validators that should be grouped together, and call the Page.Validate(String) with the name of the validation group you want to validate.
You may need to disable clientside validation for this to work properly.

Related

Validation of two sets of controls

ASP.NET WebForms 4.51
Having read things like How to validate two groups of controls with 1 button and a validation group?
I have a form with the following logical inputs:
Name (TextBox)
Last Name (TextBox)
Profession (Drop Down List)
Profession has the following items:
Bus Driver
Taxi Driver
Not Applicable
Now based on the profession I display a number of other text fields. I have required field validators on all the fields 1..3 as well as the fields for the profession (4..8).
I have a single submit button which triggers the validation. So my question is what is the easiest way to validate controls: 1..3 should the selection be Not Applicable for profession and 1..8 for the other professions from a single button.
I can think of a couple of ways but they are all "messy" and I was looking for a better approach:
1) Have two required field validators per field - one when validating for Not Applicable and one for when a profession is selected. Toggle the validation group when the profession is selected for the button.
I tried this but it does not seem to work as I still get both validators firing per field.
2) Write custom client side validators that take into account what is selected in the drop down for profession.
A maintenance nightmare. I would prefer to use any built in functionality MS provides.
So has anyone got any suggestions on how to validate the same sets of controls differently based on what has been selected in another control?
You could write a simple javascript validation script. You can not validate the javascript on serverside using "page.Isvalid".
Your only option is to write a custom validator. I just don't know why that should be a maintenance nightmare. If you're using the javascript validation you should validate the values in the code behind anyway. Otherwise the user could just disable javascript and enter anything he wants.
Hope it helps...

How to validate non entity fields but just textboxes. Also add dynamic validations

I am new to Silverlight and want to achieve validations.
I have a form with accordion control. I have controls in each section and have to have validations like Required or optional, if given a value it has to be valid like emai, phone number..... All these validations i have Dynamically enable or disable at page load.
So How i can achieve this in Silverlight 4.
In simple words how can we have Required field validator, CUstomvalidator and range validators in SilverLight.
I have gone through RIA but i am not sure how to use that on non entity fields and also Dynamically enable or disable validations.
Example i have txtFirstName, txtLastName and txtPhone. I want firstname required and Phone optional but should be validated if given some value.
All these fields are not part of any entity. Where i can add required or other attributes.
Thanks in advance.
You can add context to the validation process and allow your custom validators to be aware of some state. Fore example, you can add your page to the context and the validator can later access it to perform some conditional logic. See "RIA Services Validation: Providing ValidationContext" by Jeff Handley
How Silverlight Validation Works by Shawn Wildermuth.

asp.net calendar control firing validation controls

I have a set of validation controls on my asp.net page, to validate values in textfields. I also have a calendar control on the same page. When I click on the calendar image, the validation control message box pops up. How can I avoid that from appearing when the calendar icon is clicked?
Perhaps try to put the calendar control into a different ValidationGroup than the other controls.
If it is not in a validation group and the other controls aren't either, try to set a validation group for the other controls.
You can either use validation groups or if you don't want it to ever trigger validation set CausesValidation = false

Field validators in asp.net

Is it possible to have "Required Field Validator" controls to validate more than one field (example I have 12 textboxes that are required. I want to try an avoid having 12 RFV controls. If a validation does get triggered, is there a way to display a customized message ("textA is empty" or "textB is empty") etc.?
You can create a custom validator that goes through validates all the controls.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.customvalidator.aspx
The Required Field Validator can only validate one control at a time.
You cannot do that with a RequiredFieldValidator; you could write your own CustomValidator to do that, but the validation would be on the server side rather than on the client side.
Multiple Fields Validator - An ASP.NET Validation Control is what you need.
As mentioned by everyone else you can create your CustomValidator that can validate on the client side and on the server side. There are couple of things that you must keep in mind.
1) Make sure to expose your client script as a Web Resource. This will enable the script to be cached by the browser.
2) Use a certain attribute to target certain TextBoxes. This can be performed by giving them a certain class which will be validated in your Custom Validator control.
Hope it helps!

How to use the Validator controls with controls other than TextBox?

I want to use the Validator control to validate a FCKEditor rich text control. Is there a way to do this on either client and/or server side?
And a broader question, is there a way to use the Validator controls for anything other than text boxes?
You can use CustomValidator control to perform custom validation logic. This control actually doesn't even require ControlToValidate to be set.
It is possible to use a
CustomValidator control without
setting the ControlToValidate
property. This is commonly done when
you are validating multiple input
controls or validating input controls
that cannot be used with validation
controls, such as the CheckBox
control.

Categories

Resources