Last post Oct 01, 2020 05:44 PM by mgebhard
Member
30 Points
143 Posts
Oct 01, 2020 04:50 PM|luay20032003|LINK
I want to make the textAreaFor read only base on the value passed from controller, its work on my view without if statement , as soon I put if condition , the condition is met through my designated div tag but it never make it read only.
<div class=" row"> <div id="textArea"> <div class="col-md-4"> @Html.LabelFor(model => model.QuestionName, htmlAttributes: new { @class = "required control-label", @style = "font-weight:bold" }) </div> @if (Model.QuestionName != null) { <div class="col-md-8"> @Html.TextAreaFor(model => model.QuestionName, 4, 780, htmlAttributes : new { @class = "nowrap form-control", @readonly = "readonly" } ) @Html.ValidationMessageFor(model => model.QuestionName, "", new { @class = "text-danger" }) </div> } @if (Model.QuestionName == null) { <div class="col-md-8"> @Html.TextAreaFor(model => model.QuestionName, 4, 780, new { htmlAttributes = new { @class = "nowrap form-control" } }) @Html.ValidationMessageFor(model => model.QuestionName, "", new { @class = "text-danger" }) </div> } </div> </div>
All-Star
53081 Points
23648 Posts
Oct 01, 2020 05:44 PM|mgebhard|LINK
I'm guessing QuerionName is not null. For example, maybe it is an empty string. Try running your code through the debugger.
Member
30 Points
143 Posts
Make TextAreaFor @readonly base on value passed from controller
Oct 01, 2020 04:50 PM|luay20032003|LINK
I want to make the textAreaFor read only base on the value passed from controller, its work on my view without if statement , as soon I put if condition , the condition is met through my designated div tag but it never make it read only.
All-Star
53081 Points
23648 Posts
Re: Make TextAreaFor @readonly base on value passed from controller
Oct 01, 2020 05:44 PM|mgebhard|LINK
I'm guessing QuerionName is not null. For example, maybe it is an empty string. Try running your code through the debugger.