ASP.NET Validation help
Discussion
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:

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:

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.
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.
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
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
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.
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...
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
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
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
http://aspnet.4guysfromrolla.com/articles/073102-1.aspx
>> Edited by tim_s on Friday 18th June 17:12
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff




