[CLOSED] MVC PartialExtView

Page 1 of 5 123 ... LastLast
  1. #1

    [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:
        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
  2. #2

    RE: [CLOSED] MVC PartialExtView

    Hi,

    I was able to fix that exception (the changed are not committed yet) but unfortunately Html.RenderPartial doesn't work with PartialViewResult (Ext.Net) because it render view to the HttpContext.Response.Output directly. Therefore it doesn't rendered by that Result class


    I think it is need to write own version of the Html.RenderPartial and return string instead writing to the Output stream (again the new method should use the same approach as the Result class because view can contains Ext.Net controls). I am investigating in this direction right now


    By the way you don't want to place view as user control inside markup (<uc1:Child ...)?
  3. #3

    RE: [CLOSED] MVC PartialExtView

    Hello vladimir,

    Thanks for looking into the problem and coming up with a solution. What exactly did you change in the SVN?


    The benefit of using the Html.RenderPartial over a user control is that it will automatically have the context of our current request (model, viewdata, etc ...) passed to it. If we were to use the user control method we would be extremely limited and would have to create work arounds to pass that information between the partial views.


    I think writing our own Html.RenderPartial would be extremely beneficial. I'm going to take a crack at it tonight and see if I can get it to work -- let me know how you do as well :)


    Cheers,
    Timothy
  4. #4

    RE: [CLOSED] MVC PartialExtView

    Hi,

    I have commited the changes. Now you can use HtmlHelper inside view except RenderPartial method (still required investigation)

    First, update base toolkit and rebuild.
    Second, update extnet-mvc, add rebuilded Ext.Net assemblies and rebuild
  5. #5

    RE: [CLOSED] MVC PartialExtView

    Thanks vladimir, I'll take a swing at the Html.RenderPartial tonight and hopefully have something for you to evaluate.

    Cheers
  6. #6

    RE: [CLOSED] MVC PartialExtView

    I'm just bumping here to keep this thread a priority.

    MVC revisions are still ongoing.

    Geoffrey McGill
    Founder
  7. #7

    RE: [CLOSED] MVC PartialExtView

    Hi Timothy,

    I have committed changes


    1. Please update base toolkit
    2. Update extnet-mvc
    3. Use the following code (there is small test in the Test view)
    <%= Html.RenderExtPartial("Child") %>
  8. #8

    RE: [CLOSED] MVC PartialExtView

    Awesome vladimir, I'll test the changes and let you know if there are any problems.

    Cheers
  9. #9

    RE: [CLOSED] MVC PartialExtView

    vladimir, works like expected. I applaud your work!

    Great job implementing the support for MVC. I will let you know if I run into any other hurdles.


    Cheers
  10. #10

    RE: [CLOSED] MVC PartialExtView

    Hello vladimir,

    After some testing I found the following problem with the solution, otherwise looks really good.

    ExampleController.cs:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using System.Web.Mvc.Ajax;
    using Ext.Net;
    
    namespace Web.Controllers
    {
        public class ExampleController : System.Web.Mvc.Controller
        {
            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 id="Head1" runat="server">
        <title>Example</title>
    </head>
    <body>
        <ext:ResourceManager ID="ResourceManager1" runat="server" />
        <ext:Panel ID="Panel1" runat="server"
            Height="250"
            Title="Example"
            Width="500">
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Load">
                    <Listeners>
                        <Click Handler="#{Panel1}.load( { scripts: true, url: '/Example/Example' } );" />
                    </Listeners>
                </ext:Button>
                <ext:Button ID="Button2" runat="server" Text="Clear">
                    <Listeners>
                        <Click Handler="#{Panel1}.removeAll();" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Panel>
    </body>
    </html>
    Example.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    This is an example:<br />
    <%= Html.RenderExtPartial("Child") %>
    Child.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    This is the loaded child.
    Replication steps:

    1. Load page
    2. Click Load button
    3. Click Load button again

    Notice it couldn't load the partial again?

    If you click Clear and click Load again it fails.

    Any suggestions?

    Cheers,
    Timothy
Page 1 of 5 123 ... LastLast

Similar Threads

  1. [CLOSED] PartialExtView Button Listener
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: May 04, 2012, 3:47 PM
  2. [CLOSED] PartialExtView and Icons
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 04, 2012, 1:39 PM
  3. [CLOSED] PartialExtView
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 04, 2012, 1:32 PM
  4. [CLOSED] PartialExtView GridPanel Title
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: May 03, 2012, 7:09 PM
  5. [CLOSED] PartialExtView and Razor
    By Timothy in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 03, 2012, 3:13 PM

Posting Permissions