PDA

View Full Version : [CLOSED] How add Modules in Web Desktop



hrc
Apr 30, 2012, 3:23 AM
this is asp.net source :


<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<%@ Register Src="modules/AccordionWindow.ascx" TagPrefix="mod" TagName="AccordionWindow" %>
<%@ Register Src="modules/GridWindow.ascx" TagPrefix="mod" TagName="GridWindow" %>
<%@ Register Src="modules/WhatsNew.ascx" TagPrefix="mod" TagName="WhatsNew" %>
<%@ Register Src="modules/SystemStatus.ascx" TagPrefix="mod" TagName="SystemStatus" %>

.
.
.
<html>
<body>
.
.
.
<mod:AccordionWindow runat="server" />
<mod:GridWindow runat="server" />
<mod:SystemStatus runat="server" />
<mod:WhatsNew runat="server" />
.
.
.
</body>
</html>

I want to implement as this source in MVC.
I want to get the sample source.

Daniil
Apr 30, 2012, 12:31 PM
Hi,

Well, generally, the same. Please investigate the example.

Example View

<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<%@ Register Src ="~/Views/Test/AccordionWindow.ascx" TagName="Partial" TagPrefix="mvc" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Ext.Net.MVC v2 Example</title>
</head>
<body>
<ext:ResourceManager runat="server" />

<ext:Desktop ID="Desktop1" runat="server">
<Modules>
<ext:DesktopModule ModuleID="DesktopModule1" AutoRun="true">
<Window>
<ext:Window
runat="server"
Title="Greeting"
Html="Go to Start menu add modules dynamically" />
</Window>
</ext:DesktopModule>
</Modules>
<StartMenu runat="server" Height="200">
<MenuItems>
<ext:MenuItem runat="server" Text="Add module">
<DirectEvents>
<Click Url="/Test/AddModule1" Before="this.disable();">
<ExtraParams>
<ext:Parameter Name="desktopId" Value="Desktop1" Mode="Value" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:MenuItem>
<ext:MenuItem runat="server" Text="Add module from ASCX">
<DirectEvents>
<Click Url="/Test/AddModule2" Before="this.disable();">
<ExtraParams>
<ext:Parameter Name="desktopId" Value="Desktop1" Mode="Value" />
</ExtraParams>
</Click>
</DirectEvents>
</ext:MenuItem>
</MenuItems>
</StartMenu>
</ext:Desktop>

<mvc:Partial runat="server" />
</body>
</html>


Example Controller

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Controller = System.Web.Mvc.Controller;
using Ext.Net;
using Ext.Net.MVC;

namespace Work2MVC.Controllers
{
public class TestController : Controller
{
public ActionResult TestDesktop()
{
return View();
}

public ActionResult AddModule1(string desktopId)
{
AjaxResult r = new AjaxResult();

Desktop desktop = X.GetCmp<Desktop>(desktopId);

var m = new DesktopModule
{
ModuleID = "dyn-mod",
Shortcut = new DesktopShortcut
{
Name = "Dynamic Module"
},

Launcher = new Ext.Net.MenuItem
{
Text = "Dynamic module"
},

Window =
{
new Window
{
Title = "Dynamic Window",
Width = 300,
Height = 300,
DefaultRenderTo = Ext.Net.DefaultRenderTo.Form,
Icon = Icon.ApplicationAdd
}
},

AutoRun = true
};

desktop.AddModule(m);

return r;
}

public ActionResult AddModule2(string desktopId)
{
AjaxResult r = new AjaxResult();

Desktop desktop = X.GetCmp<Desktop>(desktopId);

var control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(new ViewUserControl().LoadControl("~/Views/Test/WhatsNew.ascx"));
control.RegisterModule();

return r;
}
}
}


WhatsNew.ascx and AccordionWindow.ascx are the same as in the example.
http://examples2.ext.net/#/Desktop/Introduction/Overview/