【问题标题】:Styling Html.textbox in asp.net MVC在 asp.net MVC 中样式化 Html.textbox
【发布时间】:2014-09-15 10:31:37
【问题描述】:

我正在尝试为文本框赋予样式,但它现在可以工作了。这是我到目前为止所做的。

<div class="modal fade" id="signin_modal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class=" modal-header">
                Create An Account
            </div>

            <div class="modal-body">

            @using(Html.BeginForm())
            { 
                <table class="signin_tbl">    
                    <tr>
                        <td class="signin_txt"><h5>Email</h5></td>
                        <td>@Html.TextBox("Name", new { style=" height:70px; "} )  </td>
                    </tr>
                    <tr>
                        <td class="signin_txt">Password</td>
                        <td class="signin_tb" >@Html.TextBox("password") </td>
                    </tr>
                </table>
            }
            </div>

这就是我得到的输出:

【问题讨论】:

  • 在发帖之前,您有没有自己尝试过解决问题?

标签: c# asp.net-mvc twitter-bootstrap bootstrap-modal


【解决方案1】:

您必须将文本框值设置为您的值,然后是您的 html 属性,例如:

@Html.TextBox("Name",[Value Or Null], new { @style=" height:70px; "} )

【讨论】:

    【解决方案2】:

    如下所示更改您的@Html.TextBox()

    @Html.TextBox("Name", null ,new { style=" height:70px; "} )
    

    @Html.TextBox() 的第二个参数是textboxvalue 而不是htmlattributes

    【讨论】:

      【解决方案3】:

      指定您要指定TextBox 方法的htmlAttributes 参数而不是它的内容。您可以像这样指定传入方法的参数:

      @Html.TextBox("Name", htmlAttributes: new { style=" height:70px; "} )
      

      【讨论】:

        猜你喜欢
        • 2015-04-05
        • 2011-02-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-08-27
        • 2010-09-07
        • 2010-11-07
        相关资源
        最近更新 更多