Monday, May 13, 2024
 Popular · Latest · Hot · Upcoming
100
rated 0 times [  101] [ 1]  / answers: 1 / hits: 19264  / 11 Years ago, thu, may 23, 2013, 12:00:00

I tried this
@Html.EditorFor(model => model.Name, , new { data_bind = value:firstName });
and other possible overloades but none of them seem to work.



The rest of code:



<script type=text/javascript>
$(document).ready(function () {

function AppViewModel() {
this.firstName = ko.observable();
this.lastName = ko.observable();
}
ko.applyBindings(new AppViewModel());
});



More From » asp.net-mvc

 Answers
34

Your 3rd parameter to EditorFor does not do what you think it should be doing.



See http://msdn.microsoft.com/en-us/library/ff406461(v=vs.98).aspx



EditorFor cannot add HTML attributes to the element. Use TextBoxFor instead:



@Html.TextBoxFor(model => model.Name, new { data_bind = value:firstName });

[#78054] Wednesday, May 22, 2013, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
keyonnaelled

Total Points: 35
Total Questions: 113
Total Answers: 99

Location: South Korea
Member since Fri, Sep 11, 2020
4 Years ago
;