loading user control on desktop shortcut click

  1. #1

    loading user control on desktop shortcut click

    I have a large application with desktop interface , every desktop icon show a window containing a user control . all user controls are loaded in page load ,that produces a slow application start. so i want to load the user control only when the user clicks the desktop shortcut ( not at the form load) . in other words i am not able to add direct event to desktop shortcut icon or desktopmodule.

    I tried the following code but it gives me error

    Server Error in '/' Application.
    -------------------------------------------------------------------------------
    The control with ID 'tLaunch' not found

    Imports Ext.Net
    Public Class _Default
        Inherits System.Web.UI.Page
        Private Sub _Default_LoadComplete(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.LoadComplete        
            CreateNewWindow(parameters)
        End Sub
        Sub CreateNewWindow(some parametes)
            Dim Win As DesktopWindow = New DesktopWindow()
            With Win
                .ID = WindowID
                .Title = WindowTitle
                .Page = Me
            End With
            MainDesktop.Controls.Add(Win)
            Dim ModuleID As String = "mdl"
            Dim m As DesktopModule = New DesktopModule()
            With m
                .ModuleID = ModuleID
                .WindowID = WindowID
                .Launcher.Text = MainMenuTitle
                .Launcher.Icon = MainMenuIcon
                .Launcher.ID = "tLaunch"
                .Launcher.DirectEvents.Click.ExtraParams.Add(New Ext.Net.Parameter("ControlPath", "~/Registration.ascx"))
                .Launcher.DirectEvents.Click.ExtraParams.Add(New Ext.Net.Parameter("WindowID", "Registration"))
                AddHandler .Launcher.DirectEvents.Click.Event, AddressOf LoadWindowControl
             End With
            MainDesktop.Modules.Add(m)
        End Sub
    
        <Ext.Net.DirectMethod()> _
        Sub LoadWindowControl(ByVal s As Object, ByVal e As DirectEventArgs)
            Dim cont As Control = LoadControl(e.ExtraParams("ControlPath"))
            CType(FindControl(e.ExtraParams("WindowID")), DesktopWindow).ContentControls.Add(cont)
        End Sub
    End Class
  2. #2
    Hi,

    LoadComplete is too late to create dynamic control, please use Load or Init events
  3. #3
    thank you Vladimir but i tried load , init and preinit but it still gives me the same error
    actually if i replaced

                .Launcher.DirectEvents.Click.ExtraParams.Add(New Ext.Net.Parameter("ControlPath", "~/Registration.ascx"))
                .Launcher.DirectEvents.Click.ExtraParams.Add(New Ext.Net.Parameter("WindowID", "Registration"))
                AddHandler .Launcher.DirectEvents.Click.Event, AddressOf LoadWindowControl
    and
    <Ext.Net.DirectMethod()> _
        Sub LoadWindowControl(ByVal s As Object, ByVal e As DirectEventArgs)
            Dim cont As Control = LoadControl(e.ExtraParams("ControlPath"))
            CType(FindControl(e.ExtraParams("WindowID")), DesktopWindow).ContentControls.Add(cont)
        End Sub
    with
    LoadWindowControl("Registration", "~/Registration.ascx")
    and

       Public Sub LoadWindowControl(ByVal WindowID As String, ByVal ControlPath As String)
            Dim cont As Control = LoadControl(ControlPath)
            CType(FindControl(WindowID), DesktopWindow).ContentControls.Add(cont)
        End Sub
    which means (calling the function in page load) it works fine
    thanks in advance
    Last edited by soradi; Jan 19, 2011 at 11:23 AM.
  4. #4
    Hi,

    Module is not widget therefore ASP.NET cannot find it, please use DirectMethod instead DirectEvent
  5. #5
    Dear Vladimir
    Sorry , but i do not know how to use DirectMethod instead DirectEvent in this situation (with desktop module) . Could you please send me a code sample
    actually it worked for module but i do not know how to add directmethod for shortcut
    Thanks
    Last edited by soradi; Jan 19, 2011 at 2:18 PM.
  6. #6

Similar Threads

  1. How to load dynamic user controls on desktop shortcut?
    By laphuynhkien in forum 2.x Help
    Replies: 4
    Last Post: Aug 23, 2012, 5:58 PM
  2. Replies: 0
    Last Post: May 16, 2012, 11:29 PM
  3. Dynamic User Control Loading
    By Rupesh in forum 1.x Help
    Replies: 0
    Last Post: Apr 08, 2011, 7:48 AM
  4. Replies: 8
    Last Post: Jan 25, 2011, 4:21 AM
  5. Dynamically loading a user control
    By kene in forum 1.x Help
    Replies: 0
    Last Post: Mar 16, 2009, 7:28 AM

Posting Permissions