2

I need disable a div depending of a variable razor. I tried a css class but not working because it is very simple disable with developer tools. there is a safe method to perform this task.? I use ASP.NET MVC 4.0

 .disableddiv {
pointer-events: none;
opacity: 0.4;

}

regards

user1596597
  • 21
  • 1
  • 3
  • Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it **in the question itself**. – Paulie_D Jun 12 '15 at 14:15
  • what do you mean by disable a div ? is it editable ? do you want to disable it's children ? Please post the view content – Bobby Tables Jun 12 '15 at 14:15
  • show us the code snippet you have tried – tech-gayan Jun 12 '15 at 14:16
  • I use a css class for disable un div, but it is very simple to reenable through development tools browsers. – user1596597 Jun 12 '15 at 14:23

2 Answers2

2

You could do something like

 @if (variable) { 
    <div>

    </div>
 }

Where variable is the variable that dictates if the div appears (like showDiv == true, for example) and div is the div you want to show.

jlasarte
  • 623
  • 8
  • 28
0

Try this:

<div style="@(Model.booleanVariable ? "disabled=disabled" : "disabled=''")">Some links</div>
Brian
  • 14,610
  • 7
  • 35
  • 43
tech-gayan
  • 1,373
  • 1
  • 10
  • 25