Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Headwrecking asp.net problem...

Options
  • 05-12-2008 1:24am
    #1
    Closed Accounts Posts: 7,097 ✭✭✭


    Here we go again!

    I have a client who has chosen a menu from another site, that he wants to have on his site that I'm designing for him.

    I did a bit of research on this menu and it is designed by using an application provided by a company called OpenCube.

    I'm using an asp.net masterpage approach to design this site for him and his menu works fine and the code will compile, except for three identical errors I'm getting:

    Element 'style' cannot be nested within element 'center'.

    If I remove the "center" tag, I get an error saying:

    Element 'style' cannot be nested within element 'body'...

    And so on...

    From googling the error, I've found that this is all part of asp.net enforcing w3c standards... It's looking like I can't have a "style" tag in an asp.net project. I'm just wondering has anyone come across this before and is there any way to use a style attribute within asp.net 2.0 without getting errors...

    The actual problem I'm having is that I cannot view my masterpage in design view because of these three errors...


Comments

  • Registered Users Posts: 2,791 ✭✭✭John_Mc


    Darragh29 wrote: »
    Here we go again!

    I have a client who has chosen a menu from another site, that he wants to have on his site that I'm designing for him.

    I did a bit of research on this menu and it is designed by using an application provided by a company called OpenCube.

    I'm using an asp.net masterpage approach to design this site for him and his menu works fine and the code will compile, except for three identical errors I'm getting:

    Element 'style' cannot be nested within element 'center'.

    If I remove the "center" tag, I get an error saying:

    Element 'style' cannot be nested within element 'body'...

    And so on...

    From googling the error, I've found that this is all part of asp.net enforcing w3c standards... It's looking like I can't have a "style" tag in an asp.net project. I'm just wondering has anyone come across this before and is there any way to use a style attribute within asp.net 2.0 without getting errors...

    The actual problem I'm having is that I cannot view my masterpage in design view because of these three errors...

    We can't help if you dont post the code


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    Sorry John!

    Basically I've three sections of code in my masterpage.master file, one after the other, that are enclosed within:

    <style type="text/css">

    </style>

    ....

    Everywhere I have these sections of code (3 places), I get 3 errors:

    Element 'Style' cannot be nested within element 'center'...

    If I remove the <center> tag, I get:

    Element 'Style' cannot be nested within element 'body'...

    It's not the code that is within:

    <style type="text/css">

    </style>

    Tags that's causing the problem, it's the tags themselves...

    They don't seem to be compatible with XHTML 1.0 Transitional Rules...

    I'm trying to put aside my habit of just lashing together whatever code that works and run with this approach of forcing a standards compliance, because if I want to get my head around asp.net, I'll have to put a sock in it for a while and just accept that I'm using a different, cautious and stricter design platform...

    Just for completeness, I've tried taking all code relating to this menu out of the masterpage.master file and just leaving in a...

    <style type="text/css">

    </style>

    ...tag and I still get an error, so the problem is obviously with the tag itself and the validation rule in operation...


  • Closed Accounts Posts: 7,097 ✭✭✭Darragh29


    I've worked out the answer to this John, the <style> tag can go in the <head> area but not in the <body> area...

    Wouldn't you think it would be as easy to put in:

    Element 'Style' cannot be nested within element 'center', the element 'style' can only be placed within element 'head'...

    As it is to put in:

    Element 'Style' cannot be nested within element 'center'

    !?!?!?!

    :mad::D:rolleyes::P;)


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Well tbh, and I don't mean to sound patronising, but style tags belong in the head element. That's kind of basic knowledge in web development and design so it's probably assumed that you already know that. You should go through the HTML and CSS tutorials on www.w3schools.com - you'll find them a huge benefit.


  • Registered Users Posts: 2,791 ✭✭✭John_Mc


    Evil Phil wrote: »
    Well tbh, and I don't mean to sound patronising, but style tags belong in the head element. That's kind of basic knowledge in web development and design so it's probably assumed that you already know that. You should go through the HTML and CSS tutorials on www.w3schools.com - you'll find them a huge benefit.

    +1


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    I hope I didn't sound to critical Darragh but if you spent a couple of days going through those tutorials it will reduce your development time significantly. Here's some other links you might find good:

    http://www.asp.net/get-started/ - from Microsoft.
    http://www.4guysfromrolla.com/ - these guys have a wealth of experience and their tutorials reflect it. The site caters for all levels.
    http://www.w3schools.com/ - as has been recommended numerous times on here and the programming forum.

    You might want to consider the Microsoft Certs as well. Have a look at http://www.microsoft.com/learning/mcp/mcts/default.mspx

    Most important of all though is to keep asking questions. That's why I hope I didn't sound to critical, we all started in the same place you're in now. We understand you're frustration too :)


Advertisement