asp.net mvc - Create and assign value back from View bag to Text box in MVC -
I have to create a text box in a view-back property in MVC; I like the mapping such as Thank you Your webpage wont updates with your view and it's up to you There is no way to get data from the form. Instead, you should use a firmly typed model binding to read your data from your action method or you can check the key in your form data, I am showing examples for both of you: Example 1: Highly typed model binding. Example 2: Reading from posted data: I hope you would like to use Example 1. However, the best practice would be to bind your view with an ideal class and use the HtmlHelper to create a text box such as: Html.EditorFor (model = & gt; model.Comments) Where in your model class the comments are property named. And your action method should accept the same model type as argument. Here's an example: And you should bind MyModel with your visual type model. I can understand that, as you are new to MVC, it can not be clear now, therefore, I would suggest to look at some basic MVC tutorials. You can start from here: @ Html.TextBox ("comments "Can I View (String) ViewBag.Comments?) But when the page is posted on the server then how can I read it? This viewbag property is not filling back. I am very new to MVC so Probably the concept is not understood.
[HTTP post] Public Fighter My Action (String Comments) {// Text Box. See Return (); }
[HTTP post] Public commentary MyAction () {// comment string comments from text box = Request.form ["comments"]; See Return (); }
[http post] Public ActionCurlutMyAction (MyMold Model) {string comments = model.Comments; }
Comments
Post a Comment