The Artima Developer Community
Sponsored Link

.NET Buzz Forum
ASP.NET validators messing up the layout of your web form

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Peter van Ooijen

Posts: 284
Nickname: petergekko
Registered: Sep, 2003

Peter van Ooijen is a .NET devloper/architect for Gekko Software
ASP.NET validators messing up the layout of your web form Posted: Nov 25, 2005 2:01 AM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by Peter van Ooijen.
Original Post: ASP.NET validators messing up the layout of your web form
Feed Title: Peter's Gekko
Feed URL: /error.htm?aspxerrorpath=/blogs/peter.van.ooijen/rss.aspx
Feed Description: My weblog cotains tips tricks and opinions on ASP.NET, tablet PC's and tech in general.
Latest .NET Buzz Posts
Latest .NET Buzz Posts by Peter van Ooijen
Latest Posts From Peter's Gekko

Advertisement

The validator controls on ASP.NET are a quite handy way to validate user input. They perform a check twice. In the browser some snippets of script block a postback to the server as long as the user input does not fulfill the requirements. They thus prevent unnecessary roundtrips. When the data does reach the server it is validated again. All of this works quite nice. But when it comes to the layout validators can have some unexpected behavior. Take this fragment of a web form.

The upper two textboxes have two validators: input is required and should fall within a certain range. This is what the page will look like in the browser when the second validator fails:

The first validator does not show up as text but as you might see it does show up as a blanks. Forcing the second validation text to the right  resulting in a text wrap. By default the validator controls always emit html. When the input is invalid it emits the message in red else it emits a string of non blank spaces. This happens also when validation makes no sense, for instance because the associated control is read-only.

ASP.NET wouldn't be asp.net if you could not change this behavior. The validator controls have a Display property. It's default value is static, resulting in the spaces demonstrated. When you set it to Dynamic it only outputs something when the validation condition is not met. A third value is None, in which case it will never emit anything.

Read: ASP.NET validators messing up the layout of your web form

Topic: Aurora/Nail Virus - a simple virus that has stumped the anti-virus firms Previous Topic   Next Topic Topic: Windows Live Custom Domains

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use