Oct 03, 2012, 6:47 AM
[CLOSED] How to use DirectMethod inside userControl (ascx) and load another usercontrol dynamically inside tab
Hi,
sample to reproduce:
user control
http://forums.ext.net/showthread.php...ll=1#post91873
So why this not working? what am I doing wrong? mb there is something I need to add to use directmethod in usercontrols?
Regards,
ViDom
sample to reproduce:
user control
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Test.ascx.cs" Inherits="controls.Test" %>
<%@ Import Namespace="controls" %>
<%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
}
[DirectMethod]
public void LoadControl(Ext.Net.Panel panel)
{
DynamicControl dynamicControl = (DynamicControl) LoadControl("/DynamicControl.ascx");
dynamicControl.ID = "dynamic_Control_in_" + panel.ID;
panel.ContentControls.Add(dynamicControl);
panel.UpdateContent();
}
</script>
<ext:Container runat="server" Layout="Border" ID="container">
<Items>
<ext:Panel runat="server" Region="North" Height="40">
<Items>
<ext:Button runat="server" Text="btn north"></ext:Button>
</Items>
</ext:Panel>
<ext:Panel runat="server" Region="Center" Layout="Fit">
<Items>
<ext:TextField runat="server" Text="center"></ext:TextField>
</Items>
</ext:Panel>
<ext:TabPanel runat="server" Region="South" Height="300" Collapsed="true" Collapsible="False" ActiveIndex="0">
<Items>
<ext:Panel runat="server" ID="tab1" Title="Tab1"></ext:Panel>
<ext:Panel runat="server" ID="tab2" Title="Tab2"></ext:Panel>
</Items>
<Listeners>
<Activate Handler="Ext.net.DirectMethods.LoadControl(p)"></Activate>
</Listeners>
</ext:TabPanel>
</Items>
</ext:Container>
second user control which should be load in directmethod<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DynamicControl.ascx.cs" Inherits="controls.DynamicControl" %>
<%@Register assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
txt.Text = this.ID;
}
</script>
<ext:TextField runat="server" ID="txt"></ext:TextField>
page:<%@ Page Language="C#" %>
<%@Register tagPrefix="uc" tagName="Test" src="controls/Test.ascx"%>
<%@Register assembly="Ext.Net" namespace="Ext.Net" tagPrefix="ext" %>
<script runat="server">
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>ViDom Example dynamic load uc by directmethod</title>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<ext:Container runat="server" Layout="Fit">
<Content>
<uc:Test runat="server"/>
</Content>
</ext:Container>
</form>
</body>
</html>
I've made this thread to simplify my previous example for faster investigate;) here is related thread:http://forums.ext.net/showthread.php...ll=1#post91873
So why this not working? what am I doing wrong? mb there is something I need to add to use directmethod in usercontrols?
Regards,
ViDom
Last edited by Daniil; Oct 09, 2012 at 10:29 AM.
Reason: [CLOSED]