我在剃刀中混用了c#和html代码。 我该如何将整体评论为一个评论,这就是代码?
@if (Request.Cookies["area"] != null && Request.Cookies["area"].Value != "")
{
<div>
<div class="search-main">
<div><input type="text" class="search-control" placeholder="Search ads..." /></div>
<div class="search-control .search-control-border" style="cursor:pointer;overflow-y:visible;">
<a style="display:block; width:100%;height:100%" onclick="expandCategoryDropdown()"> <span class="category-dropdown-text" style="float: left;margin-top: 2%;margin-left: 0.2em;">@(Request.Cookies["city"] != null ? Request.Cookies["city"].Value.ToString() : "Select Location")</span><i class="glyphicon glyphicon-chevron-down icon category-dropdown-icon" style="float: right;margin-top: 3%;"></i></a>
<div class="searh-dropdown" style="z-index:1">
<div class="inner-dropdown">
<ul style="margin-left:-38px">
@*<li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="color:black" onclick="select_cat(this,'parent')">@ViewBag.area</a></li>*@
@{
List<ListHell.CODE.Locations> lst = (List<ListHell.CODE.Locations>)ViewBag.cities;
}
<li class="select-cat-li" style="list-style-type:none">
@ViewBag.areaStr
<ul style="margin-left:-40px;">
@foreach (ListHell.CODE.Locations l in lst)
{
<li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="margin-left:10px;color:black" onclick="select_cat(this,'child')">@l.city</a></li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="search-control .search-control-border"></div>
</div>
<div><input type="button" class="form-control" placeholder="Search" value="Search" style="margin-top: -2.5% !important;margin-left: 76%;;width:20%" /></div>
</div>
}
我不想在评论中嵌入评论。只有一个评论应该做。可能吗?
答案 0 :(得分:2)
这应该可以,在我的客户端也可以。
@{/*
@if (Request.Cookies["area"] != null && Request.Cookies["area"].Value != "")
{
<div>
<div class="search-main">
<div><input type="text" class="search-control" placeholder="Search ads..." /></div>
<div class="search-control .search-control-border" style="cursor:pointer;overflow-y:visible;">
<a style="display:block; width:100%;height:100%" onclick="expandCategoryDropdown()"> <span class="category-dropdown-text" style="float: left;margin-top: 2%;margin-left: 0.2em;">@(Request.Cookies["city"] != null ? Request.Cookies["city"].Value.ToString() : "Select Location")</span><i class="glyphicon glyphicon-chevron-down icon category-dropdown-icon" style="float: right;margin-top: 3%;"></i></a>
<div class="searh-dropdown" style="z-index:1">
<div class="inner-dropdown">
<ul style="margin-left:-38px">
@*<li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="color:black" onclick="select_cat(this,'parent')">@ViewBag.area</a></li>*@
@{
List<ListHell.CODE.Locations> lst = (List<ListHell.CODE.Locations>)ViewBag.cities;
}
<li class="select-cat-li" style="list-style-type:none">
@ViewBag.areaStr
<ul style="margin-left:-40px;">
@foreach (ListHell.CODE.Locations l in lst)
{
<li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="margin-left:10px;color:black" onclick="select_cat(this,'child')">@l.city</a></li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="search-control .search-control-border"></div>
</div>
*/}
答案 1 :(得分:0)
对于多行,应为@* {code} * @
。
alt。 /*
和*/
如果您使用的是Visual Studio,也可以尝试ctrl + k + c
示例:
@*
@{
/* C# comment */
// Another C# comment
}
<!-- HTML comment -->
*@
答案 2 :(得分:0)
应该起作用
@* @if (Request.Cookies["area"] != null && Request.Cookies["area"].Value != "")
{
<div>
<div class="search-main">
<div><input type="text" class="search-control" placeholder="Search ads..." /></div>
<div class="search-control .search-control-border" style="cursor:pointer;overflow-y:visible;">
<a style="display:block; width:100%;height:100%" onclick="expandCategoryDropdown()"> <span class="category-dropdown-text" style="float: left;margin-top: 2%;margin-left: 0.2em;">@(Request.Cookies["city"] != null ? Request.Cookies["city"].Value.ToString() : "Select Location")</span><i class="glyphicon glyphicon-chevron-down icon category-dropdown-icon" style="float: right;margin-top: 3%;"></i></a>
<div class="searh-dropdown" style="z-index:1">
<div class="inner-dropdown">
<ul style="margin-left:-38px">
<!-- <li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="color:black" onclick="select_cat(this,'parent')">@ViewBag.area</a></li> -->
@{
List<ListHell.CODE.Locations> lst = (List<ListHell.CODE.Locations>)ViewBag.cities;
}
<li class="select-cat-li" style="list-style-type:none">
@ViewBag.areaStr
<ul style="margin-left:-40px;">
@foreach (ListHell.CODE.Locations l in lst)
{
<li class="select-cat-li" style="list-style-type:none"><a class="select-cat" style="margin-left:10px;color:black" onclick="select_cat(this,'child')">@l.city</a></li>
}
</ul>
</li>
</ul>
</div>
</div>
</div>
<div class="search-control .search-control-border"></div>
</div>
<div><input type="button" class="form-control" placeholder="Search" value="Search" style="margin-top: -2.5% !important;margin-left: 76%;;width:20%" /></div>
</div>
} *@
答案 3 :(得分:-1)