Click to See Complete Forum and Search --> : ASP.NET form validation and W3C-validated XHTML! Anyone else care about this?
Hello Webdevelopers !
I just registered to this forum and i have one big question:
Has anybody ever looked at the HTML rendered by ASP.NET? Has anybody tried to validate your website programmed in ASP.NET?
Now most of it goes well, but i got a problem with asp:RequiredFieldvalidator, because it generates some javascript onclick-code for the submit button. I even set EnableClientScript to false because i don't want client-side form-validation.
it also puts language="javascript" into the input type="submit"-tag and this is taht does not validate in W3C-validator?
Anybody knows how to make ASP.NET not to put this javascript onclick-code in the input submit-tag ???
CardboardHammer
07-28-2004, 11:54 AM
If you want W3C validation, it's up to you to hack things to whatever level of validation you want.
Personally, what I do is to write all dynamic content using div tags, turn off viewstate, and avoid using any controls that force viewstate.
PeOfEo
07-29-2004, 12:36 AM
You can also just use html forms and then call an asp.net script. That way you are in complete control. Basically I do not use the built in validaotrs. The best thing would be to write some java script by hand to catch the users with java script enabled before they post to the server, then run a server side script to make sure the form values are correct for those who do not have java script enabled. You may not be able to get rid of the view state tag completely. But when you do a form, make sure you put in your own name and id etc. If you do not the server will put in stuff like __ and that will kill your validation. I do not like having invalid code so I would do my forms client side. Plus I know there are lots of clients who will not settle for invalid code either. Some clients like a little thing that says the page was made correctly... so they know they are getting their moneys worth.
The whole advantage of using the built in validators is because they use the java script and you do not have to do it by hand. If you want to ditch the js, just on the page under the sub/function that is called when the button is clicked use an if statement (or a case statement).
if txtbox1.text = ""and txtbox2.text = "" then
lblblank.visible = true
lblblank2.visible = true
else if txtbox1.text = "" then
lblblank.visisible = true
else if txtbox2.text = "" then
lblblank2.visible = true
else
fire the code
end if
Just put the error messages in the lables. That will do what you want.
thank you very much.
indeed, the built-in form-validation are quite handy. but when it comes down to W3C-valid HTML, it's just a pain in the a**. as a matter of fact, M$ doesn't care a lot about W3C-standards, Internet Explorer is just the best example.
as a PHP, ASP web-developer i was used to do all the form validation by a server-side script once the form was sent, so i was really amazed by the ASP.NET form-validators. but i DO care about W3C-compliant code, so i won't use them but do the validation the same old way :-(
i.e is the field filled, is it numeric, is it > 0 etc ;-)
PeOfEo
07-30-2004, 11:52 AM
Originally posted by tini
thank you very much.
indeed, the built-in form-validation are quite handy. but when it comes down to W3C-valid HTML, it's just a pain in the a**. as a matter of fact, M$ doesn't care a lot about W3C-standards, Internet Explorer is just the best example.
as a PHP, ASP web-developer i was used to do all the form validation by a server-side script once the form was sent, so i was really amazed by the ASP.NET form-validators. but i DO care about W3C-compliant code, so i won't use them but do the validation the same old way :-(
i.e is the field filled, is it numeric, is it > 0 etc ;-) you should do it client side too, write a little js. It saves you a little bandwidth and saves the users a little time. Asp.net 2.0 is going to clean up a lot of the markup. I am going to use the validators when 2.0 comes out.
hugmup
08-12-2004, 09:36 PM
Microsoft has made the beta of Visual Studio 2005 available for download. There will be an Express version for hobbyist programmers (who outnumber professional programmers 2 to 1) that will cost less than $50 per language. I downloaded it and so far as I can tell the feature set is pretty complete.
Microsoft claims, and you can verify it yourself by downloading the beta and trying it, that VS 2005 will produce valid XHTML 1.0 code, with the exception of a few controls, which they document in detail.
The current version of VS doesn't know about XHTML.