PDA

View Full Version : [CLOSED] [#23] Page_Load event in UserControl dynamic load with dynamically control in desktop



Tactem
Oct 29, 2012, 10:11 AM
Hi guys,

I have a Desktop with one module.
If i click on a specific button, i call a direct method function in Desktop.aspx.
this function dynamic load an another module( in autorun = true).

test.ascx use also DevExpress component.

I don't fire Page_Load from this module.

The module is show.

Desktop.aspx


[DirectMethod]
public void test()
{
_test ucSimpleControl = LoadControl("~test.ascx") as _test;
DesktopModuleProxy control = Ext.Net.Utilities.ControlUtils.FindControl<Ext.Net.DesktopModuleProxy>(ucSimpleControl);
DesktopMain.AddModule(control.Module);
}


Test.ascx


<ext:DesktopModuleProxy ID="DesktopModuleProxy1" runat="server">
<Module ModuleID="tab-win" AutoRun="true">
<Shortcut Name="test" />
<Launcher Text="test" />
<Window>
<ext:Window ID="WindowsView" runat="server" Title="View" BodyBorder="1"
DefaultRenderTo="Form" Border="false" AutoScroll="true" Width="700" Height="350"
AutoShow="true" ConstrainHeader="true" Layout="AnchorLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" AnchorHorizontal="100%" AnchorVertical="100%" Resizable="true" >
<Content>
<dx:ASPxGridView ID="Grid" runat="server" Width="100%" DataSourceID="dataSource"
AutoGenerateColumns="False" KeyFieldName="0Id" OnInit="windows_init">
<Columns>
</Columns>
<Settings ShowFilterRow="True" ShowFilterRowMenu="true" ShowVerticalScrollBar="true"
ShowHorizontalScrollBar="true" VerticalScrollBarStyle="Virtual" />
</dx:ASPxGridView>
<asp:SqlDataSource ID="dataSource" runat="server" EnableCaching="true"></asp:SqlDataSource>
</Content>
</ext:Panel>
</Items>
</ext:Window>
</Window>
</Module>
</ext:DesktopModuleProxy>

Test.ascx.cs



protected void Page_Load(object sender, EventArgs e)
{
dataSource.ConnectionString = "ConnectionString";
dataSource.SelectCommand = "SELECT * FROM table";
if (!IsPostBack)
{
display();
}
else if (Session["Colonne"] != null) _listeColumn = (List<String>)Session["Colonne"];
}


Regards

Daniil
Oct 29, 2012, 1:03 PM
Hi @Tactem,

An AddModule method retrieves a DesktopModuleProxy only from a user control. It doesn't register a user control on a page. So, its life cycle is not executed.

Currently, we can suggest to handle a Window's OnLoad event. You can get controls using a FindControl method.

We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
http://examples2.ext.net/#/Loaders/Component/Direct_Method/

See a DynamicItems.ascx file.

Tactem
Oct 29, 2012, 1:22 PM
Test in my DynamicItems.ascx (I'm just the wrong extension by post). I can't use FindControl but i don't now ID of column.

display method



Configuration.getInstance().NomTable = "TableTemp";
List<String> listeColonne = GenerateData.getInstance().getColonne();
foreach (String colonne in listeColonne)
{
if (!colonne.ToLower().Contains("_id") && !colonne.ToLower().Contains("0id"))
{
AddColumnDX(colonne, colonne);
}
}

private void AddColumnDX(String nomColonne, String type)
{
try
{
GridViewDataTextColumn column = new GridViewDataTextColumn();
column.Caption = nomColonne;
column.Visible = true;
column.FieldName = type;
Grid.Columns.Add(column);
}
catch (Exception err)
{
throw err;
}
}

Daniil
Oct 29, 2012, 6:47 PM
We don't understand well what exactly a problem. Could you clarify, please?

Tactem
Oct 31, 2012, 12:06 PM

Daniil
Oct 31, 2012, 2:59 PM
Thank you for the details.

Well, and the problem is the fact that the Page_Load is not executed, right?

Our suggestion in the post #2 was to use a Window OnLoad event instead of Page_Load. Please clarify did you try it?

Baidaly
Nov 16, 2012, 10:41 PM
Opened an Issue to track this defect, see

https://github.com/extnet/Ext.NET/issues/23

Tactem
Nov 19, 2012, 7:44 AM
I use tabPanel with directMethod and javascript call now and call aspx instead of ascx



function addTabs(type, guid)
{
try {
var index = Ext.getCmp('TabPanel').items.length + 1;
var tab = Ext.getCmp('TabPanel').add(
{
id: "Tab" + index,
title: type,
closable: true,
border: false,
loader:
{
url: "../modules/module.aspx?i=" + index + "&g=" + guid,
renderer: "frame"
}
});
Ext.getCmp('TabPanel').setActiveTab(tab);
}
catch (err) {
App.direct.UnhandledException(err);
}
}

Daniil
Nov 19, 2012, 9:41 AM
Thank you for the update. It is good.

We will keep this thread opened to track an implementation of this feature.


We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
http://examples2.ext.net/#/Loaders/Component/Direct_Method/

See a DynamicItems.ascx file.

Daniil
Dec 07, 2012, 11:42 AM
We will keep this thread opened to track an implementation of this feature.



We are looking at a possibility to support an Ext.Net.IDynamicUserControl interface for Desktop. An example of using this interface is here:
http://examples2.ext.net/#/Loaders/Component/Direct_Method/

See a DynamicItems.ascx file.


Well, a Desktop works directly with a DesktopModuleProxy. It has no access to a user control. So, we can't call its methods in this case.

So, we are closing a ticket.

Fortunately, a developer is able to call a user control's method himself after a LoadControl call.