Skip to content
Advertisement

Show or Hide Field on MVC form base on the value of Viewbag using JavaScript

I am trying to Hide or Show filed on the MVC form base of a value stored in the Viewbag. the value of the Viewbag is a database return. I can see the value of the Viewbag in my JavaScript but when I run the form Hide/Show functionality is not working. I am missing something can anyone help

CHTML code

JavaScript

Javascript Code

JavaScript

C# Code to stored Viewbag value

JavaScript

Advertisement

Answer

You should change viewbag assignment:

JavaScript

remove

JavaScript

and in your javascrtipt

JavaScript

but if you use bootstrap better to use:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement