Or more specific to my code, the complete error message is:
The view 'UpdateResourceType' or its master was not found. The following locations were searched:
~/Views/StaffProfile/UpdateResourceType.aspx
~/Views/StaffProfile/UpdateResourceType.ascx
~/Views/Shared/UpdateResourceType.aspx
~/Views/Shared/UpdateResourceType.ascx
The odd thing about this is that "UpdateResourceType" is the name of the action method associated with the Update method bound to the control. It is *not* the name of the view in which the page resides. In other words, the command button is looking for a View with the same name as the action method.
The view file is named ~\Views\EditResourceTypes.aspx, the Controller file is named ~\Controllers\StaffProfileController.cs, and the controller class is called StaffProfileController, and it contains a method called UpdateResourceType.
Here are bits of the code that i hope are relevant:
In Gobal.ascx.cs:
| public class MvcApplication : System.Web.HttpApplication |
| { |
| public static void RegisterRoutes(RouteCollection routes) |
| { |
| routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); |
| routes.MapRoute( |
| "Default", // Route name |
| "{controller}/{action}/{id}", // URL with parameters |
| new { controller = "Home", action = "Index", id = "" } // Parameter defaults |
| ); |
| } |
| } |
In ~\Controllers\StaffProfileController.cs:
| [HandleError] |
| public class StaffProfileController : SWDControllerBase |
| { |
| [HttpPost] |
| [GridAction] |
| public ActionResult UpdateResourceType() |
| { |
| . |
| . |
| . |
| } |
| } |
In ~\Views\EditResourceTypes.aspx:
| <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<SWDirect.ViewModels.StaffProfileEditResourceTypesViewModel>>" %> |
| <% Html.Telerik().Grid<SWDirect.ViewModels.StaffProfileEditResourceTypesViewModel>() |
| .Name("TypesGrid") |
| .DataKeys(keys => { keys.Add(rt => rt.StaffResourceType_ID); }) |
| .DataBinding(dataBinding => dataBinding.Ajax() |
| .Select("EditResourceTypes_Ajax", "StaffProfile") |
| .Insert("InsertResourceType", "StaffProfile") |
| .Update("UpdateResourceType", "StaffProfile") |
| .Delete("DeleteResourceType", "StaffProfile") |
| ) |
| .ToolBar(commands => commands.Insert()) |
| .Columns(columns => |
| { |
| columns.Bound(rt => rt.ResourceTypeName).Width(240).Title("License"); |
| columns.Bound(rt => rt.StateName).Width(80).Title("Licensed In"); |
| columns.Command(commands => |
| { |
| commands.Edit(); |
| commands.Delete(); |
| }).Width(180); |
| }) |
| .Render(); |
| %> |
Any ideas why the command buttons are looking for a View rather than an action method?