asp.net-mvc How to change width Html.TextBox

前端 未结 5 1473
遥遥无期
遥遥无期 2020-12-31 01:25

how do you change the width of a textbox in an asp.net-mvc View

i want to have these fields side by side and the state textbox much shorter width

            


        
5条回答
  •  萌比男神i
    2020-12-31 02:15

    css

    .yourcssclassname{width:50px;}
    

    html

    <%= Html.TextBox("city", null, new{@class="yourcssclassname"})%>
    

    that should do it... you could also obviously send along a style attribute, but css classes are a better path to choose.

    string.Empty represents the default value.

    Edit: see tvanfosson's post

    fixed answer so it solves the problems mentioned in the comments.

提交回复
热议问题