Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    asp.net not w3c compliant

    Anyone know if there's a solution to this...

    I always aim to have all pages I build validate with the w3c validation, but since I've started using .NET the framework adds the name tags to the form tag which makes it non compliant.

    Is there any way around this?

    Thanks

    dominicall
    dominicall - confusing himself more and more each day

  • #2
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    your own

    you must build your own framework

    for exemple to remove the name="" to the form you must overrides RenderAttributes

    Public Class myHtmlForm : Inherits System.Web.UI.HtmlControls.HtmlForm

    Protected Overrides Sub RenderAttributes(ByVal output As HtmlTextWriter)
    output.WriteAttribute("id", Me.ID)
    output.WriteAttribute("method", Me.Method)
    output.WriteAttribute("action", YourFullPathMethod)
    End Sub

    same thing for the page ect ....

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now I just have to translate that to C#... looks like it isn't too hard though.

    I totally agree with you dominicall, it's a pain... but what's worse (er, maybe - you'd think with all of the XML and the fact that Visual Studio .NET actually writes MOSTLY correct code, they would have gone all the way... ) is dealing with other people's code that looks like:

    <font face = arial size = -1><b>Argh</b></font>
    <br>

    ... no stylesheets, no quotes around element attributes, extra spaces, unclosed tags, and to add to the frustration they don't indent their code at all.

    I think it's a crime that the code works at all in any browser. I think browsers need to start getting MUCH stricter - sure it will break a lot of pages; which will force people to learn how to code correctly, or use a tool that writes compliant code, if they care about anyone looking at their site anyway...

    What's kind of cool is that a colleague of mine developed a site in .NET and if you try to open the page in Netscape 4.x it actually just closes the browser; no errors or anything, it just disappears.

    I've tried to duplicate that effect for fun to no avail.

    P.S. Angiras, that's interesting that you're using ByVal - isn't that already the default in .NET, which makes it unnecessary using VB.NET as opposed to classic ASP?
    Last edited by whammy; 10-09-2003 at 06:35 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #4
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    inherits

    yes it is terrible not to get directly XHTML


    but to build your own framework (with own controls) is normal
    the basic framework is .... basic

    with inheritence it is so easy :


    ----------------------------------

    Namespace Angiras.FrameWork.Pages

    Public Class Page : Inherits System.Web.UI.Page

    Private Const _XMLVERSION As String = "<?xml version=""1.0"" encoding=""iso-8859-1"" ?>"

    Private Const _DOCTYPE As String = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Strict//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"">"
    Private Const _HTML As String = "<html xmlns=""http://www.w3.org/1999/xhtml"" xml:lang=""fr"" lang=""fr"">"

    Protected Head As Ang_CtrlC.HeadContent
    Protected Form As Ang_CtrlB.HtmlForm
    Protected _layout As Ang_CompCom.Layout

    Public Sub New()
    MyBase.New()
    End Sub


    Protected Overrides Sub OnInit(ByVal e As System.EventArgs)

    Head = New Ang_CtrlC.HeadContent

    Me.Controls.Add(Head)
    Me.Controls.Add(Form)

    _layout = New Ang_CompCom.Layout 'to load the content for each page
    Form.Controls.Add(_layout)

    If Not HttpContext.Current.User.Identity.IsAuthenticated Then
    _layout.AddToBody(New Ang_Comp.Login.Run)
    Else
    _layout.AddToBody(New Ang_CompCom.Content)
    End If

    Dim _ct As Ang_U.ComponentType = Me.GetComponentType()

    End Sub

    Protected Overrides Sub AddParsedSubObject(ByVal obj As Object)
    Form.Controls.Add(CType(obj, Control))
    End Sub

    Protected Overrides Sub render(ByVal writer As HtmlTextWriter)

    writer.WriteLine(_XMLVERSION)
    writer.WriteLine(_DOCTYPE)
    writer.WriteLine(_HTML)
    writer.WriteLine("<head>")
    Head.RenderControl(writer)
    writer.WriteLine("</head>")
    writer.WriteLine("<body>")
    Form.RenderControl(writer)
    writer.WriteLine("</body>")
    writer.WriteLine("</html>")

    End Sub

    End Class

    End Namespace

    ---------------------------------------

  • #5
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Byval

    P.S. Angiras, that's interesting that you're using ByVal - isn't that already the default in .NET, which makes it unnecessary using VB.NET as opposed to classic ASP?
    you must write ByVal with vbnet (or ByRef)

    unnecessary using VB.NET as opposed to classic ASP ??!!
    I don't understand ! you cannot compare the very poor asp and ASP NET

    6 object in the first case
    4000 in the second + inheritence + POO


    -----------------

    I NEVER use visual Studio as designer , I even doesn't open it

    if you prepare your strict XHTML models and your valid CSS, then as templates (ascx files) or inheritence (my way) you will get easily what you want

    I use NET as a code generator to produce HTML pages with contents
    Last edited by angiras; 10-09-2003 at 06:49 AM.

  • #6
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    From what I've used of Visual Studio .NET, I'm quite sure I'm going to be doing the same thing... it's basically a bloated version of FrontPage in that regard.



    + POO ? LOL! I think you mean OOP...
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #7
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    OOPPOO

    yes sorry in french it is POO :-))

    developpers who change from asp to asp net are generally using the same way of coding that with asp 3, in that case it is better to keep asp 3 coding , and to avoid headhake ;-))

  • #8
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Not me, I decided to use C# since it's more like Java, JavaScript, C, C++ etc. Personally I'd rather have a few headaches at first, to save more headaches in the long run!

    I prefer the stricter (and more structured) syntax, and to me VBScript has always been horrible because it allows for _very_ sloppy coding.

    Actually the changes from VBScript/VB to VB.NET are harder for me to learn than just using C# from scratch. But hey, it's all about what's most comfortable for you, anyway.

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #9
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    C#

    yes I'd like one day to jump to C# ... new NET features are 80% for it

    but with C# I'm all the time lost with
    }
    }
    }
    }
    }

    you don't know where you are

    I was programming with VB 6 and found also so limited VB script , .... specially without GoTo

  • #10
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Really C# is just like JavaScript... at least to me.
    Code:
    function whatever()
    {
         //do stuff here
    }
    ... and even JavaScript can inherit stuff, and you can add things using prototyping in JavaScript like:
    Code:
    String.prototype.trim = function()
    {
    	return this.replace(/^\s+/,'').replace(/\s+$/,'');
    }
    That emulates the old Trim() function in VBScript (client-side) exactly, and you can use it like:

    mystring = mystring.trim();

    ... when it comes to "knowing where you are" that's what indentation is for! And as much as I hate some aspects of Visual Studio .NET, it allows you to step through the code in debug mode as it executes; which is pretty cool... that way you can easily follow the program flow.
    Code:
    if (this == whatever)
    {
        if (this2 == whatever2)
        {
            //whatever!
        }
    }
    else
    {
        //else
    }
    Last edited by whammy; 10-09-2003 at 07:27 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #11
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    indent

    yes with indenting .... that's true

    you have also very practicle #region in VS

    yes ... I must try C# one day

    but I was never good with javascipt and never learnt any C or javalike langage

    just started with vb 4

  • #12
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Then you have to! It's much nicer really, I use VbScript every day and I hate it, especially how sloppy it CAN be, although I try not to be.

    But there are still stupid things that happen, especially in classic ASP. For instance, I did this today!:

    string = string & rs("somefield1") & _
    string = string & rs("somefield2") & _
    string = string & rs("somefield3") & _
    string = string & rs("somefield4")

    Looking back on it I was stupid, since I was already adding to the string I didn't need to use "& _", really it was a copy and paste mistake; I made the mistake once, and kept making it over and over...

    ... but, it didn't throw an error! Instead it turned the variable "string" into a boolean value of FALSE (don't ask me why)! To me, that's unacceptable in a programming language, because it should have thrown a syntax error.

    Instead, it took me a while to figure out that I had used two methods of concatenation together, and the error wasn't showing what the real problem was, or anywhere near it, since there was NO ERROR MESSAGE!

    At least in C, C#, Java, JavaScript, etc. it probably would have generated an error message like "You are a moron" or something.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #13
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    string

    but I never use any more vb scrip

    in sted of

    string = string & rs("somefield1") & _
    string = string & rs("somefield2") & _
    string = string & rs("somefield3") & _
    string = string & rs("somefield4")

    you can do

    s += any

    s = String.Format(varString, any1, any2, any3)

    mStringBuilder.Append(any)
    mStringBuilder.AppendForma(varString, any1, any2, any3)

    ----------------------------------------------------

    also one thing that I hate with Javalike langage is Case Sensitive

    if you write : string in VS it will correct it for : String

    with C# you get an error


    I just want to change for C# just because it seems to be more supported by Microsoft in the futures versions

    for me VB NET coding is perfect (nearlly :-))

  • #14
    Regular Coder
    Join Date
    Sep 2002
    Location
    London
    Posts
    179
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Wow

    Thanks for the replies guys - much appreciated...

    Think I'll have a look at angiras' solution... although the only compliancy error from all the code that VS.NET created was was with the adding of the name attribute to the form tag.

    Interesting discussion though.

    One thought whammy - and I'm not sure how much influence you have over this... was wondering whether it's worth setting up a different forum for .NET instead of wrapping it up with ASP. It's such a wide topic area and imvho probably deserves it.

    dominicall
    dominicall - confusing himself more and more each day

  • #15
    Regular Coder
    Join Date
    Dec 2002
    Location
    France
    Posts
    522
    Thanks
    0
    Thanked 0 Times in 0 Posts

    render

    with Overrides RenderAttributes and Render method
    you control the output of all


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •