Showing posts with label validation. Show all posts
Showing posts with label validation. Show all posts

Monday, March 26, 2012

Tabs

Does anyone know any good websites for using asp.net web controlled tabs dynamically. For example adding validation using the tabs.

Cheers

Jamie

What do you mean by:
>> adding validation using the tabs
Regards
I have a tab page which contains eight tabs. In each of the tabs is fields for a user to fill out. I was wondering when the user clicks on the next tab it will validate what was in the previous tab. e.g. they fll out their address details on one tab but forget to put in a postcode, I want it to validate this before they can access the next tab.
Cheers
This depends on if your tabs post back to update or not.
If they post back:
- Usually only the web controls that are visible in the tab are also marked Visible=true. All the rest are Visible=false. That prevents the validators that are invisible (or attached to invisible controls) from validating.
- The result allows the post back action to validate only the contents of the current tab. Its easiest on the server side, by calling Page.Validate() on the post back event handler for the Tab control (like its Click method). Then test Page.IsValid is true before allowing the tab to switch. If you want to add some client-side code to the tab's event that switches, you should call the same code used by submit buttons:
Page_ClientValidate()
If it returns true, continue switching tabs. False, stop switching tabs.
If they do not post back:
- This means all of the web control - even those that are hidden - are represented in HTML on the page. Those that are hidden have a style value of 'visibility:hidden' or 'display:none".
- If you were to call Page.Validate on the server side or Page_ClientValidate() on the client-side, all validators would fire. That includes the invisible ones. Those invisible ones would report an error (like the field hasn't been filled in yet via a RequiredFieldValidator). So it would not work.
- The solution is to use Validation Groups - available in ASP.NET 2.0 or myProfessional Validation And More. You define a group name for each tab. When you validate, you pass the group name for the tab into Page.Validate() or Page_ClientValidate().
- In addition, if you used my Professional Validation And More, the validators can be setup to detect that the data entry controls which they evaluate are invisible and will not attempt to validate them.

Thursday, March 22, 2012

tags in textbox

Hi Im using ASP.NET and C#

and I want to insert tags in a text box but its giving me an error that its a dangerous attempt so can I set any validation to allow that

Hi,

you can use theValidateRequest property to turn that on or off. Be mindfull that this opens your pages for potential hacks though so use with care.

You can also take a look at theAnti Cross Site Scripting library.

Grz, Kris.

Tuesday, March 13, 2012

Target schema for validation?

Hello everyone,

Can someone tell me which "Target schema for validation" is suitable for VS 05 web application or ASP.NET version2 application? I have set "Internet Explorer 6.0" for Target schema for validation but always get tag errors like:

Validation (Internet Explorer 6): The values permitted for this attribute do not include 'middle'.

Validation (Internet Explorer 6): Element 'table' cannot be nested within element 'span'.

Validation (Internet Explorer 6): Attribute 'size' is not a valid attribute of element 'input'.

How do I avoid these validation errors and which one is the right "Target schema for validation"? Thanks in advance.

The target schema will depend on the DOCTYPE you've chosen but ideally, you should target the latest versions so an XHTML 1.1 DOCTYPE will target the latest version of CSS (in my case the latest version in the dropdownlist was CSS2.1). However, this doesn't really have any relevance as the best method you can use is to use anon line validator and validate the final HTML that is sent to the browser.