3

使用: 私のページの 1 つで ASP .NET MVC 4 は、html ヘルパー クラスを使用して特定の幅と高さのテキスト領域が必要です。私のコードの一部を以下に示します:

    <div class="editor-label">
        @Html.LabelFor(model => model.MailSubject)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.MailSubject)
        @Html.ValidationMessageFor(model => model.MailSubject)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.MailBody)
    </div>
    <div class="editor-field">
        @Html.EditorFor(model => model.MailBody)
        @Html.ValidationMessageFor(model => model.MailBody)
    </div>

    <div class="editor-label">
        @Html.LabelFor(model => model.Content)
    </div>
    <div class="editor-field1">
        @Html.EditorFor(model => model.Content)
        @Html.ValidationMessageFor(model => model.Content)
    </div>

editorfor(model.content)のサイズ (幅/非表示) をどのように定義するのか疑問に思っています。

4

3 に答える 3

5

この質問は1年以上前のものだと思いますが、誰かが答えを探している場合に備えて、ここにあります:

Html.TextAreaFor(model => model.Field, new { rows = "", cols = "", style = "width: 90%; height: 50px;" })

スタイルをインラインで適用するか、クラス宣言を使用できます。これにより、ページ上のテキストエリアが次のようにレンダリングされます。

<textarea class="swiper-no-swiping" name="model.Field" cols="" rows="" style="width: 90%; height: 50px;"></textarea>
于 2014-01-27T21:36:48.763 に答える
2

この問題がありました。初心者なのでよくわかりませんが、以下の方法で高さ調整できました…

@Html.TextAreaFor(model => model.FullItinerary, 20, 10, null)

私はまだ幅を調整する方法を知りません、私の現在のGoogleミッション...

于 2013-09-14T23:27:50.950 に答える
0

カスタマー ヘルパーを作成するか、TextAreaFor ヘルパーの機能を拡張します。

カスタム ヘルパーの作成に役立つリソースを次に示します: http://www.simple-talk.com/dotnet/asp.net/writing-custom-html-helpers-for-asp.net-mvc/

于 2013-01-25T19:01:46.807 に答える