Is there any unofficial standard naming convention for partial views? I've seen someone suggested prefixing with "_", others postfixing with "Partial", I know the question is subjective, but since there is no official guideline, I'd like to know what the majority here uses for naming their partial views. Perhaps the most voted answer开发者_StackOverflow中文版 WILL become the standard.
Update: I'm using ASP.NET MVC 3 with Razor as the view engine, in previous versions you didn't need a convention because you had the .ascx extension
If you look at WebMatrix, the convention is to prefix Razor files that are not meant to be served directly with a leading underscore. That includes partials and layout pages. Then if you look at MvcScaffolding, you can see that the default templates generate files using the same naming convention.
Read this for an explanation as to why that convention might be used.
Razor templates can be partially rendered, even if they use a layout page and have different sections. Unlike ASPX, Razor templates have a body. I don't see the need for a naming convention, it depends on how you use the template.
I used to use "p_" as a prefix when I was using .aspx files as partial views. I pretty much just use .ascx files for partial views now, and I don't find the need to give them either a prefix or a postfix. The .ascx serves that purpose, and Visual Studio assigns a different icon to .ascx fies.
What view engine are you using?
精彩评论