2
下面的語句:ASP.NET MVC EditorFor自定義JavaScript
<%= Html.EditorFor(model => model.Material.Serial) %>
生成下面的代碼;
<div class="editor-field">
<input type="text" value="" name="Material.Serial" id="Material_Serial" class="input-validation-error">
<span id="Material_Serial_validationMessage" class="field-validation-error">Debe ingresar un serial</span>
</div>
我想通過EditorFor
語句的onkeypress
javascript屬性添加到我的投入,我試圖做到以下幾點:
<%= Html.EditorFor(model => model.Material.Serial, new{ onkeypress = "return disableEnterKey(event)"})%>
但是,這是行不通的。
好吧,但你如何保證這段代碼總是在視圖中插入時,有在模型中Material.Serial場? – fretje 2011-03-11 10:44:13