【问题标题】:Class attribute does not applay to textBoxFor类属性不适用于 textBoxFor
【发布时间】:2014-10-06 10:40:00
【问题描述】:

我正在使用以下代码根据文本更改文本框宽度 并且当前它对于输入类型的工作正常

$(document).ready(function () {
    $('.myclass').css('width', (($('.myclass').val().length)+1) * 6 + 'px'); 
});

这是正在工作的输入类型

<input type="text" class="myclass"   disabled="disabled" style="margin-right: 5px;">

但是对于下面的代码它不起作用,知道吗?

@Html.TextBoxFor(model => model.Service, new { disabled = "disabled", @class = "myclass"})

【问题讨论】:

  • Html.TextBoxFor 生成的 HTML 是什么?
  • 什么不起作用?如果宽度设置不正确?
  • @RGraham-这是 html
  • @StephenMuecke-宽度没有像在输入字段中那样一致地变化......
  • @Exception,尝试添加另一个文本框,你会发现它不起作用

标签: javascript css asp.net asp.net-mvc asp.net-mvc-5


【解决方案1】:

你应该使用类似的东西::

@Html.TextBoxFor(model => model.Service, new { disabled = "disabled", @class = "myclass"})

这是有效的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-03-15
    • 2016-07-16
    • 1970-01-01
    • 2010-10-25
    • 2010-09-30
    • 2020-03-09
    • 1970-01-01
    相关资源
    最近更新 更多