Check status and add disable property to the textarea.
foreach (var item in Model.rol_tb_approve1) { if (Model.rol_tb_form1.id == item.id_form) { <div> <h3>I. Permasalahan<h3> if (item.status == 1) { @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3"}) } else { @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3", @readonly = "readonly" }) } </div> } }
If you have more texarea, then you could do something like:
foreach (var item in Model.rol_tb_approve1) { if (Model.rol_tb_form1.id == item.id_form) { <div> <h3>I. Permasalahan<h3> if (item.status == 1) { @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3",id="firsttextarea"}) @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3",id="secondtextarea"}) @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3",id="thirdtextarea"}) } else { @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3", @readonly = "readonly",id="firsttextarea" }) @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3", @readonly = "readonly",id="secondtextarea" }) @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan, new { @style = "width:98%", @rows = "3", @readonly = "readonly",id="thirdtextarea" }) } </div> } }
You can use ternary operator
foreach (var item in Model.rol_tb_approve1) { if (Model.rol_tb_form1.id == item.id_form) { <div> <h3>I. Permasalahan<h3> @Html.TextAreaFor(x => x.rol_tb_form1.permasalahan,(item.status == 1)? new { @style = "width:98%", @rows = "3" }: {@style = "width:98%", @rows = "3", @readonly = "readonly"}) </div> } }