ASP.NET Validation help
Author
Discussion

Bonce

Original Poster:

4,339 posts

303 months

Wednesday 16th June 2004
quotequote all
Does anyone know any good resources for tips with .NET?

I'm having a hell of a time with the form validation controls (and in fact, all asp: controls) because they stick so much junk markup into the page that it's very hard to make the site which is styled with CSS render properly!


Edited to add:

anonymous-user

78 months

Wednesday 16th June 2004
quotequote all
Good luck!

You could try to force the components to render for down-level browsers which should be a little more style-able but you'll lose some of the client-side stuff.

Alternatively, you could build your own controls so that you have control over the markup. Or of course, just have it write out the raw HTML without using controls.

gopher

5,160 posts

283 months

Wednesday 16th June 2004
quotequote all
are you using vs.net ?

If so setting the value of CssClass in the properties of the control has the effect of class = "whatever" when rendered.

If you are not using vs.net then in the control properties (HTML) set the cssClass there e.g

< asp :RequiredFieldValidator id="rfvUsername" runat="server" ErrorMessage="You must enter a username" ControlToValidate="txtUserName" Display="Dynamic" CssClass="error" > </ asp:RequiredFieldValidator>

HTH

(spaces added so text would display)

Paul

anonymous-user

78 months

Thursday 17th June 2004
quotequote all
gopher said:
If so setting the value of CssClass in the properties of the control has the effect of class = "whatever" when rendered.

If I understand the original post right, it's not setting the class that's the problem. It's the fact that .Net controls produce so much extra junk with unneeded span tags and all the rest that when you come to using CSS for layout and not just simple text styling, things get rather difficult to say the least.

Bonce

Original Poster:

4,339 posts

303 months

Thursday 17th June 2004
quotequote all
Thanks for the feedback guys, but Gopher I'm afraid Lexsport has hit the crux of my problem bang on the head. The problem I'm having is with the crappy methods it selects for applying styles to form elements. Usually, wrapping the autogenerated code in autogenerated span tags does more harm to the layout than good. I've been using Literals instead of Labels and Placeholders instead of Panels to limit the junk output but I'm finding it very difficult with the form validation. Starting to think that I'll have to do all form validation server-side and manually modify the page output in order to get the results I need. Sadly this would negate a lot of the benefit of .NET...

anonymous-user

78 months

Thursday 17th June 2004
quotequote all
Looks like there's an OS project just asking to be started up there. Clean HTML generating controls for use with css layouts.

gopher

5,160 posts

283 months

Thursday 17th June 2004
quotequote all
I see, sorry I have used css without issue in the past so assumed the query was more basic.

I don't know any sites or books that cover this area specifically and it seems your problems are "general" rather than specific, although you could try posting any particular problem.

Cheers

Paul

tim_s

299 posts

278 months

Friday 18th June 2004
quotequote all
i think using a CustomValidator (from System.Web.UI.WebControls) would do the trick

http://aspnet.4guysfromrolla.com/articles/073102-1.aspx

>> Edited by tim_s on Friday 18th June 17:12

Gazeth

14 posts

295 months

Wednesday 23rd June 2004
quotequote all
try www.asp.net the forums there are spot on