I'm using MVC 4
I have in my *.ascx page the following to display a textbox on a page:
<div class="editor-field inner">
<%: Html.EditorFor(model => model.Number) %>
</div>
my model has a bool property allowEdit that indicates if the user should be allowed to edit a certain piece of information. When the value is false, I want to still show the textbox but disable it.
I've tried using jquery as follows:
<script type="text/javascript">
$(document).ready(function () {
var myModel = '<%=Model.allowEdit%>';
if(myModel == false)
{
alert("HELLO");
}
});
</script>
How can i dynamically enable/disable certain textboxes based on model value?
myModel === 'false'.'false' == falseevaluates tofalse.