VS removing style-tags - anoying

Discussion in 'Visual Studio' started by Malin, Nov 25, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I have this problem with Visual Studio 2003.

    When I add styletags to for example a textbox it is removed and replaced by the corresponding attributes (ex Height="20").

    This would not be a problem if is wasnt for the fact that Netscape compatible browsers require STYLE-tags when it comes to for example the width-attribute.

    Netscape and co dont understand the visual studio way where textboxes and so on are having width set like this:

    <asp:textbox width="20" height="20"></asp:textbox>

    Nescape and co requires the following to understand and display width properly:

    <asp:textbox style="width:20px;height:20px"></asp:textbox>

    The problem is that Visual studio constantly replaces the style tag with its own height and with attributes like my first example. This is really anoying since I have to change this all the time (everytime I have touched the code VS replaces the styletag). The solution is to always use css-classes but this does not always seem like a good solution since it would result in millions of css-classes. I usually havesome css-classesand then I combine them with additional style-tags in the controls. Sometimes all properties are the same among many controls..only the widht differs.. then I really dont want to have diffrent css-classes for all these controls - instead I add the style attribute and set the width for each control and leaves the css-class without the width-attribute.

    Is there a way to stop VS from autochanging in my code like this? If I add a styletag I want to have it there for some reason! This "excellent feature" should be possible to turn off..or? Does anybody know?

    Malin

    Post Edited (Malin) : 11/25/2004 1:49:11 PM GMT
     
  2. It's a total pain in theneck is you have multiple, width/height combos, but you could do something like the following:

    .Width20Height20 {
    width: 20px;
    height: 20px;
    }


    <asp:textbox CssClass="Width20Height20"></asp:textbox>


    Mike Reilly, Secretary/Webmaster
    Kiwanis Club of Rancho Penasquitos
    "Serving the Children of the World"
    [email protected]
    (760) 419-7429
     
  3. Thanks for your answer

    But as I understand your answeryour approachwould add multiple addidional css-classes and thats is what I am trying to avoid??
    What I want is to tell Visual Studio to stop messing with my code and just leave it as I have made it.

    Does anyone know how to do this?

    Malin
     
  4. Bruce

    Bruce DiscountASP.NET Staff

    I do not believe there's a way to do that with the current version of VS.NET.

    One of the key design goal for VS.NET 2005 I learnt from the ASP.NET team is code preservation. So expect this in the next version.

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  5. Yeah, from what I read 2005 is aiming at correcting the issue (although the issue has been around for years and they always promise to correct). There is a way to disable html formatting, but from what I understand it will only disable the coloring/fancy formatting, it will not disable the code replacement, etc.


    I couldn't find any solutions for you... just more frustrated users. That's why the only suggestion I have was the above. I know it's not ideal, but I don't see any other way around it on this version.


    Mike Reilly, Secretary/Webmaster
    Kiwanis Club of Rancho Penasquitos
    "Serving the Children of the World"
    [email protected]
    (760) 419-7429
     
  6. I guess you are right Mike, I have to use the ugly solution with many css-classesuntil VS 2005 saves me [​IMG]


    Thanks for your answers, both of you. I dont know if I have said this before but this forum is really great!


    Malin [​IMG]
     
  7. Another possible solution might be to buffer your entire output into a variable, then search/replace the undesireable tags, then output the modified variable value to the browser. Just a thought.


    Again, Ive neved used VS or .net, but I haven't read about any good solutions. If you find one, please post back so others can benefit.


    Gobble, gobble.



    Mike Reilly, Secretary/Webmaster
    Kiwanis Club of Rancho Penasquitos
    "Serving the Children of the World"
    [email protected]
    (760) 419-7429
     



  8. Mike Reilly said...

    Another possible solution might be to buffer your entire output into a variable, then search/replace the undesireable tags, then output the modified variable value to the browser. Just a thought.</BLOCKQUOTE>

    Yes, that would be an option..but I think I will go for the waiting (for the VS 2005 release). I have tried the Betabut upgrading entire solutions will have to wait until discountasp supports the new framework (2.0 is the version number I think).

    [/quote]
    Of course [​IMG]

    Once again, thanks for your tips






    Malin

    ~Postingat the DASP-forum since thebeginning ~
     
  9. FYI - This can be accomplished from code behind:

    txtTextBox.Attributes.Add("Style", "Width:20;Height:20;")

    Not sure if this is the answer your looking for but it will get the job done in IE and netscape,
    w/o having to use lots of css classes


    -Rob
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page