Regions In ASP.NET Views?

2019-01-21 18:13发布

I am making an ASP.NET MVC application with the razor engine.
And I was wondering if it's possible to use Regions in a view.

something like:

#region blabla
    <p>@Model.Name</p>
    <p>...</p>
#endregion

This does not work. Is there an alternative?

10条回答
Luminary・发光体
2楼-- · 2019-01-21 19:10

I don't have "CollapseTag" option in my context menu. What I usually do is :

  1. Select text.
  2. Goto Edit -> Outlining -> Hide Selection.

or

use Ctrl+M, Ctrl+H

I am using Microsoft Visual Studio Pro 2013.

查看更多
萌系小妹纸
3楼-- · 2019-01-21 19:11

If you download Web essential 2013 you can use regions both in your cshtml and javascript files.

Like this (thanks to @dotnetN00b for the sample in the comments section):

<!-- #region Test -->

code here

<!-- #endregion -->
查看更多
Rolldiameter
4楼-- · 2019-01-21 19:12

Divs are collapsible so you could always use them with some sort an id to kind of mimic regions.

<div id="BLABLA">...</div>
查看更多
劳资没心,怎么记你
5楼-- · 2019-01-21 19:15

regions sort-of work in views for me, I can define a region but it will not collapse. If you use @Artur's method of using Collapse Tag you're pretty much there! :)

查看更多
登录 后发表回答