MVC - how to open window in MVC project with areas

4 posts, 0 answers
  1. Gaetano
    Gaetano avatar
    8 posts
    Member since:
    Jan 2013

    Posted 12 Feb 2013 Link to this post

    Hi,
    my code doesn't work, it do not find a controller action because is located in a specific area of my MVC project.
    Can I specify in url parameter what is the area name from which call the action method?

    $("<div id = '10'/>").appendTo(document.body).kendoWindow({
            name: "window",
            resizable: true,
            width: 100,
            height: 100,
            scrollable: false,
            content: { url: 'Cliente/ClienteIndex' },
            iframe: true,
            modal: false,
            title: 'title',
            actions: ["Refresh", "Minimize", "Maximize", "Close"],
            close: function (e) {
                this.destroy();
            }
        });
  2. Daniel
    Admin
    Daniel avatar
    2118 posts

    Posted 14 Feb 2013 Link to this post

    Hello Gaetano,

    The area is part of the URL so you should use one in the following format:

    content: { url: '/AreqName/ControllerName/ActionName' }
    If you are using the script in a View you may also use the Url.Action helper to generate the correct address.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Gaetano
    Gaetano avatar
    8 posts
    Member since:
    Jan 2013

    Posted 14 Feb 2013 Link to this post

    Hi Daniel,
    unfortunatly this doesn't work, i receive a 404 Error (Not found)

    content: { url: '/Logistica/Test/Index' },

    below there are the following file:
    1. TestController.vb
    2. View.aspx
    3. LogisticaAreaRegistration.vb
    4. A piece of global.asax.vb


    File:  TestController.vb:
    Namespace JSeven
        Public Class TestController
            Inherits System.Web.Mvc.Controller
            ' GET: /Logistica/Test
            Function Index() As ActionResult
                Return View()
            End Function
        End Class
    End Namespace

    File: Index.aspx
    <%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
    <asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Index
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h2>Index</h2>
    </asp:Content>


    File: LogisticaAreaRegistration.vb
    Namespace JSeven.Areas.Logistica
        Public Class LogisticaAreaRegistration
            Inherits AreaRegistration
            Public Overrides ReadOnly Property AreaName() As String
                Get
                    Return "Logistica"
                End Get
            End Property
            Public Overrides Sub RegisterArea(ByVal context As System.Web.Mvc.AreaRegistrationContext)
                context.MapRoute( _
                    "Logistica_default", _
                   "Logistica/{controller}/{action}/{id}", _
                    New With {.action = "Index", .id = UrlParameter.Optional} _
                )
            End Sub
        End Class
    End Namespace

    File: Global.asax
    Sub Application_Start()
            AreaRegistration.RegisterAllAreas()
            RegisterGlobalFilters(GlobalFilters.Filters)
            RegisterRoutes(RouteTable.Routes)
    End Sub


    Do you have any idea?
    Thanks in advance
    Gaetano
  5. Gaetano
    Gaetano avatar
    8 posts
    Member since:
    Jan 2013

    Posted 14 Feb 2013 Link to this post

    HI Daniel,
    sorry the error was the namespace of the controller class does not match the namespace of the LogisticaAreaRegistration class.
    Modifing this mismatch, all work fine.
    Thank you.
    Gaetano
Back to Top
UI for ASP.NET MVC is VS 2017 Ready