Hello, How do I use multiple actions on the same controller?
I'm using the default project that comes up when opening a new project in asp.net mvc.
I added one more Index action on the homecontroller to accept a value from a textbox...like this
string strTest;
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Index(FormCollection frm)
{
strTest = frm["testbox"];
return RedirectToAction("Index");
}
Now,I need to display the entered value back to the user. How do I do this?
I tried this..
public ActionResult Index()
{
this.ViewData.Add("ReturnMessage", strValue);
return View();
}
Here's what I've put on my view..
<% using (Html.BeginForm())
{ %>
<p>
<%=Html.TextBox("testbox")%>
</p>
<p>
<input type="submit" value="Index" /></p>
<p>
<%= Html.ViewData["ReturnMessage"] %>
</p>
<% } %>
the compiler typically doesn't let me add another index with same constructor to display the entered message back to the user which is obvious in c# I know. But,then how do I get the message back out to the user. Thanks