Search code examples
c#asp.net-mvckendo-uikendo-asp.net-mvc

Kendo Textbox enable / Disable according to multiple statuses


I have a kendo ui textbox and i need to enable / disable that control accoding to status.It works for 1 status but when i put another status with that it's not working

Control

Below one is working

  @Html.Kendo().TextBoxFor(model => model.NewsName).HtmlAttributes(new { @class = "form-control", required = "required" }).Enable(Model.NewsStatusId != 340)

When i put two status it's not working

@Html.Kendo().TextBoxFor(model => model.NewsName).HtmlAttributes(new { @class = "form-control", required = "required" }).Enable(Model.NewsStatusId != 340 || Model.NewsStatusId != 345)

How can i use it for two statuses ?


Solution

  • I think you meant to do

    (Model.NewsStatusId != 340 && Model.NewsStatusId != 345)
    

    instead of

    (Model.NewsStatusId != 340 || Model.NewsStatusId != 345)
    

    As written, your code will always evaluate to true.