I wanted to what action a view called programmatically by specifying the action name via the ViewBag or ViewData components, but I was unable to do so. why!?
@using (Html.BeginForm(ViewData["SubmitType"], "Person"))
{...
when I run this I get:
Description: An error occurred during the compilation of a resource
required to service this request. Please review the following specific
error details and modify your source code appropriately.Compiler Error Message: CS1928:
‘System.Web.Mvc.HtmlHelper’ does not contain a
definition for ‘BeginForm’ and the best extension method overload
‘System.Web.Mvc.Html.FormExtensions.BeginForm(System.Web.Mvc.HtmlHelper,
string, string)’ has some invalid argumentsSource Error:
Line 11: Line 12: Line 13: @using
(Html.BeginForm(ViewData[“SubmitType”], “Person”)) Line 14: { Line 15:
@Html.ValidationSummary(true)
Whoops! can’t believe I forgot that the Viewdata and ViewBag are not going to hold the type string. I had to cast the return value, and everything worked!