Working with Aspnemvc 4, how to set model value with view element text in javascript MVC 4


+2 votes
asked Mar 15, 2016 by steinkamp (650 points)
I would like to have my model to be set by value of view element. And then call method in controller with model attribute value as parameter in javascript.

5 Answers

–1 vote
answered Mar 26, 2016 by GuvGet (650 points)
The model is another name for the domain layer.
commented Mar 27, 2016 by Francour (480 points)
Download the codeBe Sociable, Share
0 votes
answered Apr 8, 2016 by donne (680 points)

We do this by writing an on Focus event handler for the textarea element. Both approaches give us a reference to the desired form element.
Feel free to check it out here How to set the value of a form element using Javascript
0 votes
answered Apr 20, 2016 by solves_4986 (630 points)

In MVC, The model does not communicate with either the controller or the view.
NET MVC site for more details about these features.
You just need to create partial views in the format.
I am using sample code from ASP.NET MVC3 Razor With jQuery For Beginners - CodeProject issue is I keep getting java
0 votes
answered Apr 27, 2016 by Havent (210 points)
For more info see Model-View-Controller (MVC) with JavaScript - alexatnet.com
Look here for more details
commented Apr 28, 2016 by lbh_2571 (960 points)
ViewBag is a set of dynamic properties that can be sent to the View
commented Apr 29, 2016 by confusion (180 points)
New routes are defined in the AreaRegistration
0 votes
answered May 28, 2016 by gb_2930 (640 points)
I just wrote this cos none of the answers already here were simple enough
Check out http://www.javascript-coder.com/javascript-form/javascript-form-value.phtml support for range values

What is Geekub?

Q&A site for professional and enthusiast programmers, software developers and other technical users. With your help, we hope to work together to build a library of detailed answers to just about any question that is related to programming!







...