I'm new to MVC2, so sorry for the stupid question. I saw a good answer, but I could not find it. So my question is:
I have seen:
& lt;% @ page title = "" language = "c #" masterpagefile = "~ / view / share / Site .Master "Inherits =" System.web.mvc.view page & lt; IEnumerable & lt; MyProject.MyDB.MyProducts & gt; & gt; "& Gt%; & Lt;% @ Import Namespace = "MyProject.MyDB"% & gt; & Lt; Asp: Content ID = "Content1" content placeholder id = "content" runat = "server" & gt; Use of & lt;% (Html.BeginForm ()) {%> & Lt; Table & gt; & Lt;% foreach (Miscellaneous items in the model) {%> & Lt; TR & gt; & Lt; TD & gt; & Lt;%: item.name% & gt; & Lt; / TD & gt; & Lt; TD & gt; & Lt;%: string.format ("{0: g}", itemdate)% & gt; & Lt; / TD & gt; & Lt; / TR & gt; & Lt;%}% & gt; & Lt; / Table & gt; & Lt; Div & gt; & Lt;%: Html.TextArea ("MyTextArea")% & gt; & Lt; / Div & gt; & Lt; P & gt; & Lt; Input type = "submit" value = "send" /> & Lt; / P & gt; & Lt;%}% & gt; & Lt; / ASP: Content & gt; My Controller is:
[HTTPGet] See public functionsMyProducts (int ID) {list & lt; MyProducts & gt; MyModel = GetMyProducts (ID); See return (memold); } [HTTPS] Public Action Result Viewmeupproducts (/ * should I be kept here ???) /) {if I want the value of "MyTextArea" here is / / = Something & amp; MyModel / * From View So, looking at me in the HTTP post, my model requires the "MyTextArea" view and value. How do I get them ?? I appreciate any help
I think the following should be Work:
[HTTP Post] See Public Action ResultsMyProducts (Straight MyTextArea) A useful thing is that your action is clearly in your form Calling: Change this line:
using ;% (Html.BeginForm ()) to
To ensure that the submit action redirects it to the right action (Html.BeginForm ("ViewMyProducts", "ControllerName", HttpMethod.Post )) Using Is obtained.
As far as the model is concerned:
If you are just checking the calculation - you can create a hidden area with Co-utad, which is the number of items in "Model" Lets like:
<:: HTML.Hidden ("modelCount", Model.Count ()); But if you want the whole model - then something like this must be done:
& lt;%: Html.Hidden ("myModel", ideal ); Then you can modify your action to see something like this:
ViewMyProducts (string mytextairea, int modcount) {//. ..} or
ViewMyProducts (String Mytextairea, INMerebell & lt; MyProject.MyDB.MyProducts & gt; myModel) {// ... } Although you have access to the controller to refresh the model - so if you do not need to return the whole thing then you still get a fresh call Areas with can restore your views.
Comments
Post a Comment