Click here to Skip to main content
15,891,674 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I need to hide my div on the basis of some condition in .cshtml below is the code.
C#
@if (Submenudata.Count() > 0)
    {
        bool  var3show = false;
        <div id="nav3"  runat="server">
            <ul>
                @foreach (row row in Submenudata)
                {                                              
                            var3show = true;                            
                            <li><a href="@row .link">@row .displayName </a></li>                                                     
                    
                }
            </ul>
            @if (var3show == false)
            {
            //here i need to hide the div if var3show is false
            }
        </div>
    }


thanks in advance
Posted
Updated 18-Feb-14 0:42am
v4

1 solution

XML
<script type="text/javascript">
    var flag = "@var3show";
    if (flag == "") {
        $("#navbar3").hide();
    }
    else {
        $("#navbar3").show();
    }
</script>



JavaScript helped me to overcome this problem.
 
Share this answer
 
Comments
JoCodes 17-Feb-14 10:52am    
Mark it as a accepted solution if you already solved it yourself.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900