c# - 制作相同宽度的 Kendo UI 文本框

标签 c# html css asp.net-mvc kendo-ui

我有以下 cshtml 登录表单:

<div class="editor-label">
            @Html.LabelFor(model => model.UserEmailAddress)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserEmailAddress, new {@class = "k-textbox", style="width:200px"})
            @Html.ValidationMessageFor(model => model.UserEmailAddress)
        </div>

        <div class="editor-label">
            @Html.LabelFor(model => model.UserPassword)
        </div>
        <div class="editor-field">
            @Html.EditorFor(model => model.UserPassword, new { @class = "k-textbox", style="width:200px" })
            @Html.ValidationMessageFor(model => model.UserPassword)
        </div>

邮箱地址为typr类k-textbox,密码为text-box单行密码。因此两者都有不同的宽度。即使在我尝试明确指定宽度和类之后。我正在为 MVC 使用 KendoUI。 输出是: enter image description here

这是页面源:

 <div class="editor-label">
            <label for="UserEmailAddress">User Name (Email Id)</label>
        </div>
        <div class="editor-field">
            <input class="k-textbox" data-val="true" data-val-regex="E-mail is not valid" data-val-regex-pattern="^[a-zA-Z0-9_\.-]+@([a-zA-Z0-9-]+\.)+[a-zA-Z]{2,6}$" data-val-required="The User Name (Email Id) field is required." id="UserEmailAddress" name="UserEmailAddress" type="text" value="" />
            <span class="field-validation-valid" data-valmsg-for="UserEmailAddress" data-valmsg-replace="true"></span>
        </div>

        <div class="editor-label">
            <label for="UserPassword">UserPassword</label>
        </div>
        <div class="editor-field">
            <input class="text-box single-line password" data-val="true" data-val-required="Password required" id="UserPassword" name="UserPassword" type="password" value="" />
            <span class="field-validation-valid" data-valmsg-for="UserPassword" data-valmsg-replace="true"></span>
        </div>

这两个如何由相同的类、样式和宽度组成。

最佳答案

我认为适合您的情况的最佳解决方案是编写您自己的自定义 HTML 帮助器,这将允许您将其他信息传递到文本框。参见 this stackoverflow post获取说明。

如果您不想弄乱自定义 HTML 帮助程序,只需编写纯 HTML 代码即可:

<div class="editor-field">
    <input style="width:200px;" class="k-textbox single-line password" data-val="true" data-val-required="Password required" id="UserPassword" name="UserPassword" type="password" value="" />
    <span class="field-validation-valid" data-valmsg-for="UserPassword" data-valmsg-replace="true"></span>
</div>

关于c# - 制作相同宽度的 Kendo UI 文本框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18955299/

相关文章:

c# - 在 XNA 中使用图 block 创建和保存 map

c# - 不使用 CS0200 替换字典值

c# - 为什么 Url.IsLocalUrl 对于 ASP.NET MVC 中的本地 URL 是假的?

c# - 如何将此 IEnumerable<T> 重构为线程安全的?

css - CLASSLESS **和** IDLESS 元素的 Jsoup 选择器符号?

HTML5框架

javascript - 使用 js 滚动的 CSS 动画不起作用

javascript - 如何在提交事件时将窗口位置设置为底部?

html - Twitter Bootstrap 响应时间(有点困惑)

html - 如何修复 HTML 中 main 上的页脚覆盖