views:

21

answers:

1

What have you found to be the best way to format your ASP.NET markup files (aspx, ascx) for readability? Any tips and/or tricks?

I'm looking for comments on indentation, line-wrapping, naming schemes, <%-- --%> commenting, or whatever you can think of.

+4  A: 

I usually just use ctrl+k, ctrl+d shortcut in Visual Studio and let it format my code for me.

You can customize the way Visual Studio formats the code by going to Tools -> Options -> Text Editor -> HTML -> Format

However, when there are a lot of attributes in an element I usually organize the elements like this:

<cc1:MediaGallery ID="MediaGalleryControl" runat="server"
                  AllowUpload="false"
                  AllowUploadPreview="false"
                  MediaLibraryName="Downloads"
                  DisplayActiveContent="true"
                  DisplayFileCount="true"
                  TransformationName="Community.Transformations.MediaLibrary"
                  FooterTransformation="Community.Transformations.MediaLibraryFooter"
                  HeaderTransformation="Community.Transformations.MediaLibraryHeader"
                  HideFolderTree="true"
                  FileIDQueryStringKey="fileid"
                    />
orandov