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

    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) {
  2. Daniel
    Daniel avatar
    2177 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.

    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. 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">
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    File: LogisticaAreaRegistration.vb
    Namespace JSeven.Areas.Logistica
        Public Class LogisticaAreaRegistration
            Inherits AreaRegistration
            Public Overrides ReadOnly Property AreaName() As String
                    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()
    End Sub

    Do you have any idea?
    Thanks in advance
  4. 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.
Back to Top