Coffeehouse Thread

8 posts

Standards Compliance in ASP Web Development

Back to Forum: Coffeehouse
  • User profile image
    lesmemphis

    Basically I'm a C# developer, but over the last couple of months I've been put on a website project. C# being the foundation of my knowledge, I naturally chose ASP.NET to design the website in.

     

    I’ve learned a lot and I am quite proud of what I’ve accomplished so far. But I’ve noticed that my biggest mistake is standards compliance and using the right tools for what I want to achieve.

     

    So, I’d like to hear your opinions on the matter and give advice, suggestions, or alternatives to some concepts I’ve come to use, but am not sure is the best choice:

    • asp:menu – I’ve had a couple of problems, like the z-index bug in IE.
    • scripts – when and how to use them?
    • posting data between pages and to 3rd party sites? http post? sessions?
    • sending emails – I’ve heard many different opinions on the best way to do that!
    • multi-views?
    • datagrids vs asp:table?
    • What’s the best way to keep a website dynamic? When should css sheets be used?
    • Another thing is, I’ve noticed IE being way more lenient on code than open source browsers, why is this?

    I’d love any further advice on standards compliance. Also, go check out the website and let me know what you think, I’d love some suggestions and advice! Learning is after all the base class for success!

     

    http//:www.semper-backpacking.com/

  • User profile image
    itsnotabug

    my humble opinions/observations (you may find them completely wrong in your application):

    1) use jQuery for all client side. forget the built-in controls. this won't win me many friends around here Smiley

    2) see 1

    3) depends. i like session state for smaller sites, 3rd party? yes and yes (post and querystrings)

    4) if possible use the virtual smtp server on the iis box

    5) what about multi-views?

    6) i like datagrids but you have to tweak it (look at the ondatabound event), but it really depends on your context

    7) ummm. in terms of updating (like a cms)? or just not using static text? ALWAYS

    8) cuz microsoft likes to keep things easy (not really but the opposite is true also, things work in firefox... not so in ie)

  • User profile image
    spivonious

    I wouldn't consider myself a web programmer, so take this with a grain of salt.

     

    scripts - use them when you don't need server-side processing. They're faster and don't require a page refresh. Same with controls. If you don't need server-side processing, use plain HTML.

     

    posting data between pages - session unless security is of no concern, then post is okay. Remember that anyone can type in a post variable

     

    sending emails - I'd use .NET's System.Net.Mail

     

    CSS sheets should always be used.

     

    IE was made before a lot of the open source browsers. Therefore it had to work with websites that were coded before standards existed.

     

     

     

    About the site...no offense, but it would benefit from a professional designer. Functionally it appears fine. Design-wise it feels like it's from 2002.

  • User profile image
    kettch

    itsnotabug said:

    my humble opinions/observations (you may find them completely wrong in your application):

    1) use jQuery for all client side. forget the built-in controls. this won't win me many friends around here Smiley

    2) see 1

    3) depends. i like session state for smaller sites, 3rd party? yes and yes (post and querystrings)

    4) if possible use the virtual smtp server on the iis box

    5) what about multi-views?

    6) i like datagrids but you have to tweak it (look at the ondatabound event), but it really depends on your context

    7) ummm. in terms of updating (like a cms)? or just not using static text? ALWAYS

    8) cuz microsoft likes to keep things easy (not really but the opposite is true also, things work in firefox... not so in ie)

    Why would talking abou jQuery get you into trouble? jQuery is now fully supported under ASP.NET 4 and VS2010. It's been blessed by The Gu.That should be enough for most people here. Tongue Out

  • User profile image
    figuerres

    itsnotabug said:

    my humble opinions/observations (you may find them completely wrong in your application):

    1) use jQuery for all client side. forget the built-in controls. this won't win me many friends around here Smiley

    2) see 1

    3) depends. i like session state for smaller sites, 3rd party? yes and yes (post and querystrings)

    4) if possible use the virtual smtp server on the iis box

    5) what about multi-views?

    6) i like datagrids but you have to tweak it (look at the ondatabound event), but it really depends on your context

    7) ummm. in terms of updating (like a cms)? or just not using static text? ALWAYS

    8) cuz microsoft likes to keep things easy (not really but the opposite is true also, things work in firefox... not so in ie)

    ...  Well some of the controls are ok for some things...

    but the menu control is not very good IMHO.

     

    JQ - i just started to use it and so far i like it!

     

    the DataGridView IMHO is a really nice control and you can do a lot of cool things with it.

     

    Multi-View very handy at times....

  • User profile image
    W3bbo

    Point-by-point discussion:

    • asp:menu is part of the WebControls series of controls. Don't use them. Stick to HtmlControls (which have a 1:1 mapping between themselves and their generated markup)
    • There are exceptions to this rule: The Validation controls are good, and the PlaceHolder control is another essential.
    • Try to avoid server-generated scripts wherever possible. Write your own or use a third-party framework, use a Script Compactor to make them small. If you're making a publically-visible page that's got more than 10KB of scripts to download then you're probably doing something wrong.
    • In your page classes, use the HttpWebRequest/HttpWebResponse classes to handle HTTP requests to off-site servers. There also exists the WebClient class that simplifies things (but you lose some degree of control).
    • There is only one way to send email in ASP.NET (unless you want to write your own SMTP client) and that's using System.Net.Mail. You might get confused by articles from before 2005 that refer to System.Web.Mail which is where the SmtpClient was located in earlier versions of the framework.
    • Multi-views? No idea what they are, sorry.
    • Use neither. Instead use <table runat="server"> (which maps to HtmlTableControl) and add your own rows manually as necessary. Don't forget to make use of <thead> and <tbody> where appropriate.
    • CSS has nothing to do with a website being "dynamic"
    • Because IE was built over a long period of time. The Trident engine used in IE goes back to IE4 in 1998 and Microsoft has to maintain backwards compatibility. Note that if you have IE in "Standards Mode" then it is a lot less forgiving of non-compliance, especially so in IE8 and later.

    As for your site:

    • It takes a while to load, but I'll put that down to it being located in SA.
    • The logo on the right of the homepage is a simple image, yet is 78KB. You can easily make that around 12KB or so.
    • I'm happy to report no scripting errors, although Firefox complains the "-moz-outline" property is not recognised. Use "outline" instead.
    • I can't speak to you about the aesthetics because you say you're a developer and not a designer, but if you did design the visuals I'll just say it needs more work.

    In conclusion:

     

    Not a bad job, especially judging by most ASP.NET developer's work, but has a bit of a way to go towards being a first-class website.

  • User profile image
    figuerres

    W3bbo said:

    Point-by-point discussion:

    • asp:menu is part of the WebControls series of controls. Don't use them. Stick to HtmlControls (which have a 1:1 mapping between themselves and their generated markup)
    • There are exceptions to this rule: The Validation controls are good, and the PlaceHolder control is another essential.
    • Try to avoid server-generated scripts wherever possible. Write your own or use a third-party framework, use a Script Compactor to make them small. If you're making a publically-visible page that's got more than 10KB of scripts to download then you're probably doing something wrong.
    • In your page classes, use the HttpWebRequest/HttpWebResponse classes to handle HTTP requests to off-site servers. There also exists the WebClient class that simplifies things (but you lose some degree of control).
    • There is only one way to send email in ASP.NET (unless you want to write your own SMTP client) and that's using System.Net.Mail. You might get confused by articles from before 2005 that refer to System.Web.Mail which is where the SmtpClient was located in earlier versions of the framework.
    • Multi-views? No idea what they are, sorry.
    • Use neither. Instead use <table runat="server"> (which maps to HtmlTableControl) and add your own rows manually as necessary. Don't forget to make use of <thead> and <tbody> where appropriate.
    • CSS has nothing to do with a website being "dynamic"
    • Because IE was built over a long period of time. The Trident engine used in IE goes back to IE4 in 1998 and Microsoft has to maintain backwards compatibility. Note that if you have IE in "Standards Mode" then it is a lot less forgiving of non-compliance, especially so in IE8 and later.

    As for your site:

    • It takes a while to load, but I'll put that down to it being located in SA.
    • The logo on the right of the homepage is a simple image, yet is 78KB. You can easily make that around 12KB or so.
    • I'm happy to report no scripting errors, although Firefox complains the "-moz-outline" property is not recognised. Use "outline" instead.
    • I can't speak to you about the aesthetics because you say you're a developer and not a designer, but if you did design the visuals I'll just say it needs more work.

    In conclusion:

     

    Not a bad job, especially judging by most ASP.NET developer's work, but has a bit of a way to go towards being a first-class website.

    Multi-Views:

     

    a container that holds a collection of "View" controls and only shows one at any time, think of it as a set of Panel / DIV controls.

    like the Panel if it is not visible then it and it's content are not rendered on the client but are still part of the server state.

    usefull for a multi part operation where you want to show different blocks of content and user input w/o using multiple pages.

     

  • User profile image
    itsnotabug

    kettch said:
    itsnotabug said:
    *snip*

    Why would talking abou jQuery get you into trouble? jQuery is now fully supported under ASP.NET 4 and VS2010. It's been blessed by The Gu.That should be enough for most people here. Tongue Out

    wow! that's great news about jQuery (and an indictment of how behind-the-times i am).

     

    i agree figuerres. some data-centric controls are invaluable... i was mostly talking about the controls that try to do *too much* like the menu and wizard. as soon as you require functionality/styling that's not offered out of the box, you're stuck trying to over-ride their rendering and at that point, you may have well just rolled your own solution < that's the only way to get the granular level of control.

     

    i also love the multi-view. i think the wizard is derived from it, so if you need wizard-like functionality, the multi-view exposes a very useful event model to exploit.

     

    as far as email goes, you can spend a lot of time trying to get your relay rules set with your stmp server but if you have access to the virtual stmp that comes with windows server you can send emails with something like this:

     

    //create the mail message

    {
     MailMessage mail = new MailMessage();

     //set the addresses
     mail.From = new MailAddress("me@myDomain.com");
     mail.To.Add("you@yourDomain.com");

     //set the content
     mail.Subject = "Hello.";
     mail.Body = "<b>Wow, this is easy!</b>.";
     mail.IsBodyHtml = true;

     SmtpClient smtp = new SmtpClient("127.0.0.1");

     smtp.Send(mail);
    }

     

    you can even write the email files directly to the transport folders, bypassing the network layer completely. check this resource for email guidance: http://www.systemnetmail.com/

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.