Visual Studio .NET keeps changing my code

Last post 11-18-2007 6:23 PM by akaEdge. 3 replies.

Sort Posts:

  • Visual Studio .NET keeps changing my code

    10-28-2003, 12:25 PM
    • Member
      155 point Member
    • paulha
    • Member since 08-12-2003, 10:01 AM
    • Posts 31
    In the VS IDE, I will format my code all nice and neat (in other words readable) when I am coding a ASPX page in HTML mode. I will switch to DESIGN mode or run the project and when I come back to HTML mode, my code is ALL messed up and once again un-readable.

    HOW CAN I STOP THIS??? You have to be able to format your code to be able to read it, right?

    An example is below:

    MY FORMATTING- NICE - NEAT - READABLE

    <tr>
    <td class="headtxt" align="right">Address:</td>
    <td>
    <asp:textbox
    id="txt_BillingAddress"
    runat="server"
    tabIndex="5"
    BorderStyle="Inset"
    CssClass="mdtxt"
    ToolTip="Please enter billing address"
    MaxLength="100"
    Columns="50">
    </asp:textbox>
    <asp:RequiredFieldValidator
    id="req_BillingAddress"
    tabIndex="6"
    runat="server"
    BorderStyle="None"
    ErrorMessage="Billing Address is required!"
    ControlToValidate="txt_BillingAddress">
    </asp:RequiredFieldValidator>
    </td>
    </tr>



    VISUAL STUDIO TURNS IT INTO THIS

    <tr>
    <td class="headtxt" align="right">Address:</td>
    <td><asp:textbox id="txt_BillingAddress" runat="server" tabIndex="5" BorderStyle="Inset" CssClass="mdtxt"
    ToolTip="Please enter billing address" MaxLength="100" Columns="50"></asp:textbox>
    <asp:RequiredFieldValidator id="req_BillingAddress" tabIndex="6" runat="server" BorderStyle="None" ErrorMessage="Billing Address is required!"
    ControlToValidate="txt_BillingAddress"></asp:RequiredFieldValidator></td>
    </tr>


    PLEASE tell me this is a way to prevent this. Thanks in advance!!
  • Re: Visual Studio .NET keeps changing my code

    10-28-2003, 12:50 PM
    • Contributor
      2,365 point Contributor
    • timmcb
    • Member since 11-04-2002, 4:29 PM
    • Redmond, WA
    • Posts 469
    • AspNetTeam
    This is a major problem with VS 2002/2003. It has been fixed in the version of VS currently under development but it took a major re-architecture to do it. There are only a couple choices to work-around this and none of them are optimal:

    1) Set the HTML editor to open in source view. Turn off auto-formatting. This will allow you to format the HTML how you want. Do not switch to design view. If for some reason you must switch to design view, when you switch back to HTML view you can type Ctrl+Z to undo the formatting done by the design view.

    2) Turn on auto formatting and accept the way it formats your code. Note, the auto-formatter will try to fix the changes that the design view made. It is also possible to write your own auto-formatter for VS 2003. If your interested in that let me know and I'll find the link to an MSDN article that explains it.
    Tim McBride

    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Visual Studio .NET keeps changing my code

    10-28-2003, 12:50 PM
    • Member
      566 point Member
    • johndund
    • Member since 10-30-2002, 8:34 PM
    • Posts 112
    • AspNetTeam
    Hi,

    In tools -> options -> text editor -> html/xml > format

    there is a "Apply automatic formatting" option for when you save or switch views.

    Hope this helps,
    John
  • Re: Visual Studio .NET keeps changing my code

    11-18-2007, 6:23 PM
    • Member
      43 point Member
    • akaEdge
    • Member since 09-27-2007, 12:09 AM
    • Posts 14

    Just thought I would update this for those people who want to change this in VS 2005 - I wanted to stop HTML ID's being changed when pasting in Source View

    Tools -> Options -> Text Editor -> HTML -> Miscellaneous

    Uncheck "Auto ID elements on paste in Source view" for my problem,

    and uncheck "Format HTML on paste" for the one at the top of this thread
     

     

Page 1 of 1 (4 items)