2016-11-24 12 views
2

コールでCSSスタイルdisplay: noneを使用していますが、動作しません。CSSスタイル{Display:none}がhtmlattributeで機能していません

<img id="Img" src="~/abc/def.jpg" style="height: 120px; max-width: 100%; width: 280px;" class="img-responsive" /> 
@Html.TextBoxFor(m => m.dP, new { htmlAttributes = new { @class = "form-control has-feedback-left file btntag", @onchange = "openFile(event)", @style="display: none;", @type="file", placeholder = "Upload Display Picture" } }) 
@Html.ValidationMessageFor(model => model.dP, "", new { @class = "text-danger" }) 

答えて

0
<img id="Img" src="~/abc/def.jpg" style="height: 120px; max-width: 100%; width: 280px;" class="img-responsive" /> 
@Html.TextBoxFor(m => m.dP, new { @class = "form-control has-feedback-left file btntag", onchange = "openFile(event)", style="display: none;", @type="file", placeholder = "Upload Display Picture" }) 
@Html.ValidationMessageFor(model => model.dP, "", new { @class = "text-danger" }) 

上記ヘルパーのHTML属性を定義するための正しい方法です。 (余分な "htmlAttributes = new"部分を削除してください。)

+0

が、私はそれをcodeed ...... BeginContext( "〜/ビュー/ UserRegistration/UserRegistration.cshtml"、12489、14、真の); –

0

以下のようにTextBoxForの構文を変更してください。

@Html.TextBoxFor(m => m.dP, new { @class = "form-control has-feedback-left file btntag", onchange = "openFile(event)", style="display: none;", @type="file", placeholder = "Upload Display Picture" })

のみclasstypeこれら二つはC#のキーワードであるとして@の接頭辞が必要です。だから、@classとしてHTML属性にするために@を前に付けあいまいさを解決し、@type

にもhtmlAttributes一部を除去します。基本的な構文は次のとおりです。あなたは私を示唆したが、今私は新しいコンパイルエラーに直面していますよう

@Html.TextBoxFor(m => m.Email, new { ... }) // ... is your HTML attributes 
+0

あなたが私に提案したように私はそれをコードしましたが、今私は新しいコンパイルエラーに直面しています...... BeginContext( "〜/ Views/UserRegistration/UserRegistratio n.cshtml"、12489、14、true); –

+0

@TittiTowelあなたは完全なエラーを表示することができます。画像を追加して、私にリンクをもらえればいいですか..画像リンクを与えるには、http://imgur.com/ –

+0

を使用してください。準備ができました。画像と感謝をあなたにお届けします。 –

関連する問題