[CLOSED] [2.1] MVC Partial View

  1. #1

    [CLOSED] [2.1] MVC Partial View

    Hi,

    I'm trying to load a mvc partial view with parameters that returns a usercontrol, and I'm unable to do it. I do that in v1.x.

    This is my test case:

    MAIN VIEW
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <%@ Register Src="~/Views/Shared/UserControl.ascx" TagName="Control" TagPrefix="custom" %>
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <custom:Control runat="server" />
        </form>
    </body>
    </html>
    USERCONTROL
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:Panel ID="MyPanel" runat="server" Layout="FitLayout" Title="Panel with partial view" Height="500">
        <Loader runat="server" Url="/Area/Sample/MyPartialView">
            <LoadMask ShowMask="true" Msg="Custom loagind message..." UseMsg="true" />
            <Params>
                <ext:Parameter Name="containerId" Value="#{MyPanel}" Mode="Value" />
                <ext:Parameter Name="dummy" Value="(new Date()).getTime()" Mode="Raw" />
            </Params>
        </Loader>
    </ext:Panel>
    CONTROLLER (dummy parameter is not collected)
    public ActionResult MyPartialView(string containerId)
            {
                return new Ext.Net.MVC.PartialViewResult(containerId, Ext.Net.RenderMode.AddTo);
            }
    PARTIAL VIEW USERCONTROL
    <%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <ext:Label runat="server" Text="Partial View Label" />
    I tried to change Mode property of Loader to Frame, Html, Script but i wasn't lucky.

    How I have to load a mvc partial view in Ext.NET 2.1?

    Thanks
    Last edited by Daniil; Aug 23, 2012 at 12:57 PM. Reason: [CLOSED]
  2. #2
    Hi,

    You can set up
    Scripts="true"
    for the loader, but the recommended Mode to render partial views is Script (instead of default Html).
    <Loader runat="server" Mode="Script">
    In that case you should set up WrapByScriptTag to false for a PartialViewResult.

    Also set up SingleControl to true if you need the Label to participate in layout logic.

    Example
    public ActionResult MyPartialView(string containerId)
    {
        Ext.Net.MVC.PartialViewResult r = new Ext.Net.MVC.PartialViewResult(containerId, Ext.Net.RenderMode.AddTo);
        r.SingleControl = true;
        r.WrapByScriptTag = false;
        return r;
    }
  3. #3
    It works with this properties (Mode="Script" and Scripts="true") in loader and changes in controller

    Thanks!
  4. #4
    Scripts="true"
    should not be required with
    Mode="Script"
    if you set up
    r.WrapByScriptTag = false;
  5. #5
    Quote Originally Posted by Daniil View Post
    Scripts="true"
    should not be required with
    Mode="Script"
    if you set up
    r.WrapByScriptTag = false;
    Yes, you are right!

Similar Threads

  1. [CLOSED] Partial View Error
    By peter.campbell in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Feb 10, 2012, 10:32 AM
  2. Javascript not work in partial view mvc.ext.net
    By theblackcat_2902 in forum 1.x Help
    Replies: 9
    Last Post: Aug 24, 2011, 10:31 AM
  3. [CLOSED] RegisterOnReadyScript in MVC partial view
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 22
    Last Post: Aug 10, 2011, 4:17 PM
  4. [CLOSED] MVC- How to display a Partial View from a window
    By SymSure in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Apr 08, 2011, 11:32 AM
  5. Can't add record to store from partial view
    By craig2005 in forum 1.x Help
    Replies: 14
    Last Post: Jan 05, 2011, 11:59 PM

Tags for this Thread

Posting Permissions