Asp.net Mvc Structure
Ok
I have the开发者_开发知识库 following view structure:
Views/Level1/Level2/View.aspx
Views/Level1/Level2/DisplayTemplates/MyDisplayTemplate.ascx
for this to work, inside my action I have to do this:
return View("Areas/Area1/Views/Level1/Level2/View.aspx", model);
All good in the hood...
Except. The display templates are obviously lost or something? I have UiHint on the model and i tried calling
Html.DisplayFor(x=>x.Property, "PathToDisplayTemplate")
too but nothing seems to want to make it do its thang :(
any clues?
Note: Read comments also ...
Wouldn't you just have:
Html.DisplayFor(x=>x.Property, "MyDisplayTemplate")
This will then look for a DisplayTemplates
folder in the same folder as the view and look for MyDisplayTemplate.ascx
inside there.
Also if you have this exactly: return View("Areas/Area1/Views/Level1/Level2/View.aspx", model);
there might be something wrong, i can't think why you would need to be so explicit.
MVC will look for a view in the folder for that controller (For example; HomeController, there will be a Folder called "Home" in views)
It will then look to match the name of your action to the name of the view within that folder. For example if you have public ActionResult Index() it will look in Views/Home/Index.aspx
meaning you only need to write "return View()" or "return View(model)" if you are passing in a model.
Hope i haven't misunderstood your requirements and telling you something you already know,
Regards, Kohan.
From my experience one wouldn't program a partial view in the controller but would instead use a normal view and then handle the partials in that view or in it's viewmodel, I'll try and see how to do it ur way but heres at least how I do it.
Edit- oh yeh
return View("Areas/Area1/Views/Level1/Level2/View.aspx", model);
would return a normal view but since ur asking for a display temp then that should be a ascx so it could just be that which is the issue.
精彩评论