@ Html.TextArea行和列 [英] @Html.TextArea rows and cols

查看:61
本文介绍了@ Html.TextArea行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习ASP.NET MVC4。有些人认为这些概念对我来说是新的。我今天的问题是:



当我使用@ Html.TextArea()时,如何控制表格中的行数和列数



这是我的代码,如果它有帮助,但这是一个相当普遍的问题



 <   div     id   =  contact-form >  
@using(Html.BeginForm())
{
@ Html.LabelFor(model => model.Name)< br / >
@ Html.TextBoxFor(model => model.Name)< br / >
@ Html.ValidationMessageFor(model => model.Name)< br < span class =code-keyword> / >

@ Html.LabelFor(model => model.Phone )< br / >
@ Html.TextBoxFor(model => model.Phone)< br / >
@ Html.ValidationMessageFor(model => model.Phone)< br / >

@ Html.LabelFor(mod el => model.Email)< br < span class =code-keyword> / >
@ Html.TextBoxFor(model => model.Email)< br / >
@ Html.ValidationMessageFor(model => model.Email) < br / >

@ Html.LabelFor(model => model.Comments)< br / >
@ Html.TextAreaFor(model => ; model.Comments,new {rows = 10,columns = 40})< br / >
@ Html.ValidationMessageFor( model => model.Comments)< br / >

< 按钮 type = 提交 > 发送< / button >
< 按钮 类型 = 重置 > CLEAR < / button >
}

< / div >



谢谢

解决方案

行和列不建议使用HTML表吗?

 @ Html.TextAreaFor(model = >  model.Description, new  {@class =   whatever-class,@ cols = < span class =code-digit> 80 ,@rows =  10 })





试试这个,看看


 @ Html.TextAreaFor(model => model.descricao,htmlAttributes:new {@class =form-control,@ rows = 5,@ cfs = 30})


I'm trying to learn ASP.NET MVC4. Some if these concepts are new to me. My question today is:

How do I control the amount of rows and cols in a form when I use @Html.TextArea()

Here's my code if it helps, but it is a pretty general question

<div id="contact-form">
    @using(Html.BeginForm()) 
    {
        @Html.LabelFor(model => model.Name)<br />
        @Html.TextBoxFor(model => model.Name)<br />
        @Html.ValidationMessageFor(model => model.Name)<br />
    
        @Html.LabelFor(model => model.Phone)<br />
        @Html.TextBoxFor(model => model.Phone)<br />    
        @Html.ValidationMessageFor(model => model.Phone)<br />
    
        @Html.LabelFor(model => model.Email)<br />
        @Html.TextBoxFor(model => model.Email)<br />
        @Html.ValidationMessageFor(model => model.Email)<br />
    
        @Html.LabelFor(model => model.Comments)<br />
        @Html.TextAreaFor(model => model.Comments, new { rows= 10, columns= 40 })<br />
        @Html.ValidationMessageFor(model => model.Comments)<br />
    
        <button type="submit">SEND</button> 
        <button type="reset">CLEAR</button> 
    }
    
</div>


Thanks

解决方案

Wouldn't "rows" and "columns" suggest using a HTML table to you??


@Html.TextAreaFor(model => model.Description, new { @class = "whatever-class", @cols = 80, @rows = 10 })



Try this and see


@Html.TextAreaFor(model => model.descricao, htmlAttributes: new { @class = "form-control", @rows= 5, @cols = 30 })


这篇关于@ Html.TextArea行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆