Hide DIV with DropDownList

Sometimes we need to hide some static part of the view. With help comes by jQuery and CSS.
First we need add script like below:


$(‘.extensionFields’).change(function () {
if ($(this).val() == ‘1’) {
else {


Use ordinary DropDownList with ignition CSS Class: extensionFields

@Html.DropDownList(“Id”, null, htmlAttributes: new { @class = “form-control extensionFields” })

Create DIV class name divrek and style display:none attribute to hide on start everything what is in div:

<div class=”divrek” style=”display:none”>Every thing that you wont to hide</div>

and now when we choose Id with value 1 contents of devrek suddenly appears.

Leave a Reply

Your email address will not be published. Required fields are marked *