I have the following html code that I would like to change it to use html helper methods instead.
<div class="form-group col-sm-4 col-md-4 col-lg-4">
<label>Date of Birth</label>
<div class="input-group date" id="dtp">
<input name="Birthday" id="txtBirthday" class="form-control" onfocus="$(this).next().trigger('click')" onkeydown="event.preventDefault()" />
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
@Html.ValidationMessageFor(m => m.Birthday)
</div>
I want to change the above html code to the following using html helper methods but I don't know how to write onkeydown="event.preventDefault()" and $(this).next().trigger('click')" in the below code.
<div class="form-group col-sm-4 col-md-4 col-lg-4">
@Html.LabelFor(m => m.Birthday)
@Html.EditorFor(m => m.Birthday, new { @class = "form-control", id="txtBirthday" })
@Html.ValidationMessageFor(m => m.Birthday)
</div>
@Html.TextBoxFor()or ifEditorFor, then the format is@Html.EditorFor(m => m.Birthday, new { htmlAttributes = new { @class = "form-control" } })@Html.TextBoxFor()but how can I writeonkeydown="event.preventDefault()"in it ?$('#Birthday').keydown(function(e) { ... });$(this).next().trigger('click')"as an attribute makes no sense so not clear what your trying to do with that.