带kendoui文本编辑器的Razor

带kendoui文本编辑器的Razor,razor,kendo-ui,kendo-asp.net-mvc,Razor,Kendo Ui,Kendo Asp.net Mvc,选中复选框时,我正试图显示剑道UI文本编辑器。 但是它不起作用,你能帮我吗 @if (Model.IsAlert!=true) { <td> @(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" })) </td> } @if(Model.IsAlert!=true)

选中复选框时,我正试图显示剑道UI文本编辑器。
但是它不起作用,你能帮我吗

@if (Model.IsAlert!=true)
{
  <td>                   
     @(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" }))             
  </td>
}
@if(Model.IsAlert!=true)
{
@(Html.Kendo().Editor().Name(“解释”).HtmlAttributes(新的{style=“display:show”}))
}

您当前的方法仅在屏幕的初始加载时呈现/evaluate Model.IsAlert

我建议删除if语句,并将此td默认为hidden,然后根据模型中的属性,通过映射到checkbox控件的onChange事件处理程序更改它

<td id="thingToHide" hidden="hidden">
 @(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" }))             
</td>

@(Html.Kendo().Editor().Name(“解释”).HtmlAttributes(新的{style=“display:show”}))
还有一些jquery代码:

<script type="text/javascript">
 $(document).ready(function () { // On page load method, check model and show textbox if needed
      var model = @Html.Raw(Json.Encode(Model)); // get model example is taken from http://stackoverflow.com/questions/16361364/accessing-mvcs-model-property-from-javascript
      if (model.IsAlert) { // If model IsAlert is true, show Explanation field
           $("#thingToHide").show();
      }
 });

 $("#YourCheckBoxId").on("change", function() {
     $("#thingToHide").toggle();
 });
</script>

$(document).ready(函数(){//)在页面加载方法上,选中模型并显示文本框(如果需要)
var model=@Html.Raw(Json.Encode(model));//获取模型示例取自http://stackoverflow.com/questions/16361364/accessing-mvcs-model-property-from-javascript
如果(model.IsAlert){//如果model IsAlert为true,则显示解释字段
$(“#thingToHide”).show();
}
});
$(“#YourCheckBoxId”)。在(“change”,function()上{
$(“#thingToHide”).toggle();
});

祝你好运,拉达

您当前的方法将仅在屏幕的初始加载上呈现/evaluate Model.IsAlert

我建议删除if语句,并将此td默认为hidden,然后根据模型中的属性,通过映射到checkbox控件的onChange事件处理程序更改它

<td id="thingToHide" hidden="hidden">
 @(Html.Kendo().Editor().Name("Explanation").HtmlAttributes(new { style = "display:show" }))             
</td>

@(Html.Kendo().Editor().Name(“解释”).HtmlAttributes(新的{style=“display:show”}))
还有一些jquery代码:

<script type="text/javascript">
 $(document).ready(function () { // On page load method, check model and show textbox if needed
      var model = @Html.Raw(Json.Encode(Model)); // get model example is taken from http://stackoverflow.com/questions/16361364/accessing-mvcs-model-property-from-javascript
      if (model.IsAlert) { // If model IsAlert is true, show Explanation field
           $("#thingToHide").show();
      }
 });

 $("#YourCheckBoxId").on("change", function() {
     $("#thingToHide").toggle();
 });
</script>

$(document).ready(函数(){//)在页面加载方法上,选中模型并显示文本框(如果需要)
var model=@Html.Raw(Json.Encode(model));//获取模型示例取自http://stackoverflow.com/questions/16361364/accessing-mvcs-model-property-from-javascript
如果(model.IsAlert){//如果model IsAlert为true,则显示解释字段
$(“#thingToHide”).show();
}
});
$(“#YourCheckBoxId”)。在(“change”,function()上{
$(“#thingToHide”).toggle();
});

祝你好运,拉达

您当前的方法将仅评估Model.IsAlert!=在屏幕的初始加载时为true。。。您可能需要实现一些javascript/jquery来隐藏/显示基于该值的文本框?谢谢somuch Dinglemeyer,您的方法正在工作…:)如果它起作用了,请随意标记为答案:)很高兴你让它起作用了!您当前的方法将仅评估Model.IsAlert!=在屏幕的初始加载时为true。。。您可能需要实现一些javascript/jquery来隐藏/显示基于该值的文本框?谢谢somuch Dinglemeyer,您的方法正在工作…:)如果它起作用了,请随意标记为答案:)很高兴你让它起作用了!非常感谢您的回复,我可以这样写吗,因为我是剑道和剃刀新手,我怀疑我们是否可以在.HtmlAttributes(new{condition})中写一个条件@(Html.Kendo().EditorFor(model=>model.Explantion).HtmlAttributes(new{@style=model.IsAlert?“display:show white space:pre:“display:none”})是否有效?我认为应该有效,尽管@style需要有一个;在中列出的每个样式之间,所以“display:show;white space:pre;”将是您希望格式化该部分的方式。试试看!!:)非常感谢您的回复,我可以这样写吗,因为我是剑道和剃刀新手,我怀疑我们是否可以在.HtmlAttributes(new{condition})中写一个条件@(Html.Kendo().EditorFor(model=>model.Explantion).HtmlAttributes(new{@style=model.IsAlert?“display:show white space:pre:“display:none”})是否有效?我认为应该有效,尽管@style需要有一个;在中列出的每个样式之间,所以“display:show;white space:pre;”将是您希望格式化该部分的方式。试试看!!:)