Jul 20, 2016, 9:21 AM
[CLOSED] Usercontrol, DirectMethod, Object --> Get Value
Hi Guys,
Working on a large desktop project and looking for an answer. Check following files.
I would like to get the value of Textfield tfTest (Test2.ascx) to be shown in codebehind when using a DirectMethod. But I can't. Can you explain why and what can I do to achieve my goal. I don't get an error. Just no value..
Default.aspx
Test2.ascx
Martin
Working on a large desktop project and looking for an answer. Check following files.
I would like to get the value of Textfield tfTest (Test2.ascx) to be shown in codebehind when using a DirectMethod. But I can't. Can you explain why and what can I do to achieve my goal. I don't get an error. Just no value..
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Iwise.DefaultTest" %>
<%@ Register Src="Test1.ascx" TagPrefix="mod" TagName="Test1" %>
<%@ Register Src="Test2.ascx" TagPrefix="mod" TagName="Test2" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>I-Wise</title>
</head>
<body>
<ext:ResourceManager runat="server" ID="rsmTestIwise"/>
<ext:Desktop ID="dtIwiseTest" runat="server">
<StartMenu Title="Keuze menu" Icon="Application" Height="500">
<ToolConfig>
<ext:Toolbar runat="server" Width="110">
<Items>
<ext:Button runat="server" Text="Settings" Icon="Cog" />
</Items>
</ext:Toolbar>
</ToolConfig>
<MenuItems>
<ext:MenuItem ID="mnuTestDM" runat="server" Text="Open Test1" Icon="Car">
<Listeners>
<Click Handler="App.dtIwiseTest.getModule('modTest1').createWindow();"/>
</Listeners>
</ext:MenuItem>
</MenuItems>
</StartMenu>
</ext:Desktop>
<%--Modules from User controls--%>
<mod:Test1 ID="ucTest1" runat="server"/>
<mod:Test2 ID="ucTest2" runat="server"/>
</body>
</html>
Default.aspx.csusing System;
using System.Web.UI;
using Ext.Net;
namespace Iwise
{
public partial class DefaultTest : Page
{
[DirectMethod(ShowMask = true)]
public void ShowWindow(string name)
{
LoadControl($"{name}.ascx");
}
}
}
Test1.ascx<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test1.ascx.cs" Inherits="iWise3.Test.Test1" %>
<ext:DesktopModuleProxy runat="server">
<Module ModuleID="modTest1">
<Window>
<ext:Window runat="server"
Icon="CarAdd"
Width="450"
Height="400"
Layout="Fit"
Title="Overzicht ingevoerde kilometerstanden"
Resizable="False"
Minimizable="False"
ID="winTest">
<TopBar>
<ext:Toolbar runat="server">
<Items>
<ext:Button runat="server" ID="btnToevoegenKmStandTest" Text="Open Test2" Icon="Add">
<Listeners>
<Click Handler="App.dtIwiseTest.getModule('modTest2').createWindow();" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<Items>
</Items>
</ext:Window>
</Window>
</Module>
</ext:DesktopModuleProxy>
(.cs = empty code file)Test2.ascx
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test2.ascx.cs" Inherits="iWise3.Test.Test2" %>
<ext:DesktopModuleProxy runat="server">
<Module ModuleID="modTest2">
<Window>
<ext:Window runat="server"
Icon="Table"
Width="400"
Height="260"
Layout="Fit"
Title="Invoer kilometerstand"
Modal="True"
Resizable="False"
Minimizable="False"
ID="winTest2">
<Items>
<ext:FormPanel
runat="server"
Frame="true"
Border="false"
BodyPadding="10"
DefaultAnchor="100%"
ID="frmTest1">
<FieldDefaults
LabelSeparator=" "
LabelAlign="Top"
LabelWidth="100"
LabelStyle="font-weight:bold;font-size:smaller;" />
<Defaults>
<ext:Parameter Name="margin" Value="0 0 10 0" Mode="Value" />
</Defaults>
<Items>
<ext:TextField
runat="server"
Flex="1"
EmptyText="Add Value"
HideTrigger="True"
LabelAlign="Top"
FieldLabel="Kilometer stand"
ID="tfTest"
AllowBlank="False"
/>
</Items>
<DockedItems>
<ext:Toolbar runat="server" Dock="Bottom">
<Items>
<ext:ToolbarFill runat="server"/>
<ext:Button runat="server" Icon="Exclamation" text="Try to get value field in DM">
<Listeners>
<Click Handler="DMKSI.ucTest2.TestObject();"/>
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</DockedItems>
</ext:FormPanel>
</Items>
</ext:Window>
</Window>
</Module>
</ext:DesktopModuleProxy>
Test2.ascx.cs[
using System.Diagnostics;
using Ext.Net;
namespace iWise3.Test
{
public partial class Test2 : System.Web.UI.UserControl
{
[DirectMethod(Namespace = "DMKSI")]
public void TestObject()
{
string number = tfTest.Text;
Debug.WriteLine($"Value: {number}");
}
}
}
Martin
Last edited by fabricio.murta; Jul 22, 2016 at 9:08 PM.