Oct 23, 2014, 7:55 AM
DirectEvent or DirectMethod and dynamic UserControl
Hi.
I simpled Desktop sample and add a button to user control .
I will add a click event for button .
what is my mistake?
tanks.
with code:
I simpled Desktop sample and add a button to user control .
I will add a click event for button .
what is my mistake?
tanks.
<%@ Page Language="C#" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
[DirectMethod(ShowMask=true)]
public void AddNewModule()
{
Desktop.GetInstance().RemoveModule("add-module");
DesktopModuleProxy control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(this.LoadControl("TabWindows.ascx"));
control.RegisterModule();
}
</script>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET Examples</title>
<link href="resources/desktop.css" rel="stylesheet" />
</head>
<body>
<ext:ResourceManager runat="server"> </ext:ResourceManager>
<ext:Desktop ID="Desktop1" runat="server">
<Modules>
<ext:DesktopModule ModuleID="add-module">
<Shortcut Name="Render dynamic module" Handler="function() {#{DirectMethods}.AddNewModule();}" X="200" Y="100" TextCls="x-long-label">
</Shortcut>
</ext:DesktopModule>
</Modules>
</ext:Desktop>
</body>
</html>
and <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TabWindows.ascx.cs" Inherits="test2.TabWindows" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<ext:DesktopModuleProxy runat="server">
<Module ModuleID="tab-win">
<Shortcut Name="Tab Window" />
<Launcher Text="Tab Window" Icon="Tab" />
<Window>
<ext:Window runat="server"
Icon="Tab"
Width="740"
Height="480"
ConstrainHeader="true"
Border="false"
Layout="Fit"
Title="Tab Window">
<Items>
<ext:Panel runat="server" Title="Tab Text 1" Border="false" Html="<p>Something useful would be in here.</p>">
<Items>
<ext:Button runat="server" ID="btn1" Text="test">
<DirectEvents>
<Click OnEvent="btn1_Click"></Click>
</DirectEvents>
</ext:Button>
<ext:TextField ID="text1" runat="server"></ext:TextField>
</Items>
</ext:Panel>
</Items>
</ext:Window>
</Window>
</Module>
</ext:DesktopModuleProxy>
with code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Ext.Net;
namespace test2
{
public partial class TabWindows : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
[DirectMethod]
public void btn11_Click()
{
}
protected void btn1_Click(object sender, DirectEventArgs e)
{
}
}
}
Last edited by Daniil; Oct 24, 2014 at 6:03 AM.
Reason: Please use [CODE] tags