Reputation: 3
I have a dropdown list that is populated on a content page like this
<%: Html.DropDownListFor(x => x.SelectedName, Model.NameList) %>
<input name="btnGo" type="submit" value="GO" />
When the user selects the name and click the GO button, I have an HTTP Action that gives me the name
[HttpPost]
public ActionResult SelectName(string SelectedName)
{
...
}
Now I want to take that name and set a lable on the master with the SelectedName in MVC2 how is this accomplished?
Upvotes: 0
Views: 810
Reputation: 73122
Remember, this is not Web Forms. :)
In other words, you can't do this in the Controller action:
someLabel.Text = "foo"
Your best bet would be to put the text you want in the ViewData:
[HttpPost]
public ActionResult SelectName(string SelectedName)
{
...
ViewData["SelectedText"] = "some text";
return View();
}
And then set the Label to that in your Master View:
<span><%: ViewData["SelectedText"] %></span>
Upvotes: 1