开发者

Formatting Markup Files in ASP.NET

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.


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"
                    />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜