BoundForGlory
BoundForGlory

Reputation: 4417

Populating a telerik window with a partial view MVC3

This is an MVC3 app. I have a Telerik grid and when a row is clicked, i want to popup a telerik window. The window will be populated with a partial view. My grid is fine. This is the code for the window:

  @(Html.Telerik().Window()
    .Name("EditTaskWindow")
    .Visible(false)
     .Content(@<text><iframe id="ifrmEditTask" width="600" height="500" marginheight="0"   marginwidth="0"></iframe></text>)

)

This is the javascript that opens the window:

   function WFTaskGrid_onRowSelect(e) {
       var url = "@(Url.Content("~/WorkflowTask/Edit/"))" + "1/2/3";
        $('#ifrmEditTask').attr('src',url);
        $('#EditTaskWindow').data('tWindow').center().open();
     }

But when i click a row on my grid the window pops up but i get a 404 cannot find "WorkflowTask/Edit/1/2/3" Here is my controller:

    public ActionResult _Edit(string id, string sub, string log)        
       {
           return PartialView();
      }

I added this to global.asax:

   routes.MapRoute(
     "EditTasks", // Route name
    "{controller}/{action}/{id}/{sub}/{log}", // URL with parameters
     new { controller = "WorkflowTask", action = "Edit", id = UrlParameter.Optional, sub = UrlParameter.Optional, log = UrlParameter.Optional } // Parameter defaults
 );

Still get the 404. Does anyone know why? Thanks

Upvotes: 0

Views: 1426

Answers (1)

John x
John x

Reputation: 4031

you have and ActionResult

public ActionResult _Edit(string id, string sub, string log)       

and you have specified the route as

routes.MapRoute(
     "EditTasks", // Route name
    "{controller}/{action}/{id}/{sub}/{log}", // URL with parameters
     new { controller = "WorkflowTask", action = "Edit", id = UrlParameter.Optional, sub = UrlParameter.Optional, log = UrlParameter.Optional } // Parameter defaults
 );

see the error??

the underscore you are putting before the action result _Edit

and then you have

  var url = "@(Url.Content("~/WorkflowTask/Edit/"))" + "1/2/3";

still the underscore is missing

possible remedy with the exisiting route is to add a action name like

[ActionName("Edit")]
public ActionResult _Edit(string id, string sub, string log)  

Upvotes: 1

Related Questions