MVC3 JSCOLOR values
-
13-06-2021 - |
Question
I am very new to MVC, and I am trying to get the value from JScolor in my view, but I am hitting a brick wall, and there doesnt seem to be any info out there, so how is it done? I should add I am doing this in the view, and trying to update via EF4.1.
La solution
If you are using a model in this view. You can simply write
@Html.TextBoxFor(m => m.selectedColor, new { @class = "Color" })
Where selectedColor is a property in the model
In the controller, you well get that model's property
Example Controller Code
public ActionResult SaveColor(SelColor model){
string myColor = SelColor.selectedColor;
...
..
}
In the above code, SelColor is model's name SaveColor is controller's Action
In the view, use Html.BeginForm() to call the desired controller's action.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow