Feb 02, 2010, 10:07 PM
[CLOSED] MVC PartialExtView
Hello vladimir,
If you check the following example you will notice an exception being thrown when using the Html.RenderPartial:
ExampleController.cs:
1. Load page
2. Open Firebug notice an exception? (A ViewUserControl can only be used inside pages that derive from ViewPage or ViewPage<TViewItem>.
This should work, replace the Example action with the following:
Thanks for looking into this it's a hold up on our end from moving forward with MVC :(
Cheers,
Timothy
If you check the following example you will notice an exception being thrown when using the Html.RenderPartial:
ExampleController.cs:
public class ExampleController : Controller
{
//
// GET: /Example/
public ActionResult Index()
{
return View();
}
public ActionResult Example()
{
var result = PartialExtView();
result.ContainerId = "Panel1";
result.RenderMode = RenderMode.AddTo;
return result;
}
}
Index.aspx:<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />
<ext:Panel ID="Panel1" runat="server"
Height="250"
Title="Example"
Width="500">
<AutoLoad Url="/Example/Example" />
</ext:Panel>
</body>
</html>
Example.ascx:<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="System.Web.Mvc.Html" %>
This is an example:<br />
<% Html.RenderPartial("Child"); %>
Child.ascx:<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
This is the loaded child.
Replication steps:1. Load page
2. Open Firebug notice an exception? (A ViewUserControl can only be used inside pages that derive from ViewPage or ViewPage<TViewItem>.
This should work, replace the Example action with the following:
public ActionResult Example()
{
return PartialView();
}
Reload the page and it works, loads the Child.ascx.Thanks for looking into this it's a hold up on our end from moving forward with MVC :(
Cheers,
Timothy