0

I have mixed c# and html code in razor. how can I comment the whole as a one comment, this is the code?

@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>
}

I dont want embed comment within comment. Just one commenting should do. Possible?

user786
  • 3,902
  • 4
  • 40
  • 72

4 Answers4

3

This should work, it's working in my client.

@{/* 


@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>


*/}
Mahogany
  • 509
  • 4
  • 17
1

Should be @* {code} * @ for multiline. alt. /* and */

You can also try ctrl + k + c if you are using Visual Studio

Example:

@*
    @{
        /* C# comment */
        // Another C# comment
    }
    <!-- HTML comment -->
*@

Similar Post answer

Community
  • 1
  • 1
Bebolicious
  • 116
  • 1
  • 11
  • Tried: <%-- --%> <% %> @/* */@ – Bebolicious Apr 24 '19 at 11:24
  • keep editing not working. I take it as no to the answer. NOT POSSIBLE – user786 Apr 24 '19 at 11:28