[CLOSED] PartialViewResult Problem

  1. #1

    [CLOSED] PartialViewResult Problem

    Hello,

    The following example demonstrates an issue with the PartialViewResult from the MVC project:

    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"
            Width="400">
            <Content>
                Click Load to Start.
            </Content>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Load">
                    <Listeners>
                        <Click Handler="#{Panel1}.load( { scripts: true, params:{container: '#{Panel1}' }, url: '/Example/Example' } );" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Panel>
    </body>
    </html>
    Example.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <asp:Label ID="Label1" runat="server" Text="Successfully Loaded Word" />
    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 : Controller
        {
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult Example(string container)
            {
                return new Ext.Net.MVC.PartialViewResult(container, RenderMode.RenderTo);
            }
        }
    }
    Replication steps:

    1. Load page
    2. Click Load button
    3. Notice the contents from Example.ascx is loaded outside of the panel?

    Any suggestions?

    Cheers,
    Timothy
  2. #2

    RE: [CLOSED] PartialViewResult Problem

    Hi,

    I think the panel's body should be defined as container. Try this
    container: #{Panel1}.body.id
  3. #3

    RE: [CLOSED] PartialViewResult Problem

    Works for basic content, but what if my Example.ascx contained the following:

    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <ext:Panel ID="Panel2" runat="server"
        Layout="fit">
        <Content>
            Example<br />
            123
        </Content>
    </ext:Panel>
    The Layout="fit" no longer works.

    Cheers,
    Timothy
  4. #4

    RE: [CLOSED] PartialViewResult Problem

    Hi,

    Why do you use Layout="fit" with Content? Layout uses with Items only.
    If you meant that Panel1 has Layout="Fit" and you need to place Panel2 as Panel1's item then need use


    container: '#{Panel1}'
    and
    return new Ext.Net.MVC.PartialViewResult(container, RenderMode.AddTo);
  5. #5

    RE: [CLOSED] PartialViewResult Problem

    Thanks for the response vladimir,

    When I use your suggestion (examples below) I still don't get the layout fit to work:

    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"
            Layout="Fit"
            Height="250"
            Width="400">
            <Content>
                Click Load to Start.
            </Content>
            <Buttons>
                <ext:Button ID="Button1" runat="server" Text="Load">
                    <Listeners>
                        <Click Handler="#{Panel1}.load( { scripts: true, params: { container: '#{Panel1}' }, url: '/Example/Example' } );" />
                    </Listeners>
                </ext:Button>
            </Buttons>
        </ext:Panel>
    </body>
    </html>
    Example.ascx:
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <ext:Panel ID="Panel2" runat="server">
        <Content>
            Example<br />
            123
        </Content>
    </ext:Panel>
    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 : Controller
        {
            public ActionResult Index()
            {
                return View();
            }
    
            public ActionResult Example(string container)
            {
                return new Ext.Net.MVC.PartialViewResult(container, RenderMode.AddTo);
            }
        }
    }
    Appreciate your patience, I'm still trying to wrap my head around this new PartialViewResult :)

    Cheers,
    Timothy
  6. #6

    RE: [CLOSED] PartialViewResult Problem

    Hi,

    Wrap partial view's panel by FitLayout
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    <ext:FitLayout runat="server">
        <Items>
            <ext:Panel ID="Panel2" runat="server">
                <Content>
                    Example<br />
                    123
                </Content>
            </ext:Panel>
        </Items>
    </ext:FitLayout>
  7. #7

    RE: [CLOSED] PartialViewResult Problem

    Works thanks!

Similar Threads

  1. [CLOSED] Migrating to 2: PartialViewResult
    By PhilG in forum 2.x Legacy Premium Help
    Replies: 4
    Last Post: May 21, 2012, 9:27 AM
  2. [CLOSED] PartialViewResult and Model
    By Timothy in forum 1.x Legacy Premium Help
    Replies: 26
    Last Post: Feb 14, 2011, 9:23 PM
  3. [CLOSED] Universal PartialViewResult Problem
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 11
    Last Post: Dec 28, 2010, 1:27 PM
  4. Problem with GMapPanel in MVC2 using PartialViewResult
    By tiramisu in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Nov 23, 2010, 7:56 AM
  5. [CLOSED] Refresh problem with PartialViewResult
    By Stefanaccio in forum 1.x Legacy Premium Help
    Replies: 4
    Last Post: Jul 02, 2010, 6:19 AM

Posting Permissions