简体   繁体   中英

Styling Html.textbox in asp.net MVC

I am trying to give style to the textbox but its now working.This is what i have done so far.

<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>

And this is what i am getting as output:

在此输入图像描述

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

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

Change your @Html.TextBox() as shown below :

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

The second parameter of @Html.TextBox() is value of textbox and not htmlattributes .

Specify you want to specify the htmlAttributes argument of the TextBox method instead of it's content. You can specify the argument passed in to the method like this:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM