Dynamic Creation Of Controls

  1. #1

    Dynamic Creation Of Controls

    *Hi Geoff/Team,

    Firstly, thanks for a great framework. It's going to save me days!


    I'd like to be able to create controls (Windows, Tabs) dynamically in the Codebehind (Codefile in VS2008). I'm have trouble, and I suspect this isn't support yet (maybe AjaxMethods from V0.7?).


    I have a ViewPort with a button. The button has the following :


    *
    <ext:ScriptManager ID="ScriptManager2" runat="server">	
    	<CustomAjaxEvents>
    		<ext:AjaxEvent Target="btnProfile" OnEvent="btnProfile_Click" />
    	</CustomAjaxEvents>
    
    </ext:ScriptManager>
    <ext:Button ID="btnProfile" runat="server" Text="Load Profile" ></ext:Button>


    I then have the following in the CodeBehind :


    protected void btnProfile_Click(object sender, AjaxEventArgs e)
    {
    	Coolite.Ext.Web.Window window = new Coolite.Ext.Web.Window();
    
    	window.Title = "User Profile";
    
    	window.ID = "UserProfile";
    
    	Page.Form.Controls.Add(window);
    	window.Show();
    
    }


    Nothing happens (or I get an error message about this.UserProfile being null (I assume because it wasn't created beforehand.


    I'm intending to use this type of functionality throughout the systems (Windows, Forms, Tabs) etc, due to the dynamic nature of the application. Can I do this type of things now with v0.6, do I have to wait for v0.7, or is it coming after that version?


    Cheers


    Steve


  2. #2

    RE: Dynamic Creation Of Controls

    Hi Steve,

    Dynamic creation of controls during an AjaxEvent is not currently supported. We're expecting to include this functionality in a future release, although it will not be included with the v0.7 release.*


    The Controls must be present on the Page during the initial Page_Load.*


    Geoffrey McGill
    Founder
  3. #3

    RE: Dynamic Creation Of Controls

    Hi Geoff,

    Thanks for the quick reply. I guess at a push I could reuse a single pre-created window. So if I could use :

    // Change the currently loaded page in the window, to reuse a single window.
    window1.AutoLoad= "~/loadthispage.aspx"

    What doesn't seem to work is things such at :

    window1.Width=Unit.Pixel(400);
    this doesn't take affect either. Is there a way to this? I've tried calling window1.DoLayout() but this has no effect.

    For creating tabs (I couldn't find an example of this), is there a way to create a new tab, which autoloads an HTML resource? Or would this have to be done completely on the client side script?

    Thanks in advance for taking the time to answer.

    Cheers

    Steve
  4. #4

    RE: Dynamic Creation Of Controls

    Hi Steve,

    Functionality for setting the Width/Height of a Window during an AjaxEvent/AjaxMethod has been added/fixed in the v0.7 release.*


    We're also adding some helpers to the v0.7 for dynamically creating Tabs.*


    Geoffrey McGill
    Founder
  5. #5

    RE: Dynamic Creation Of Controls

    *Excellent. Thanks Geoff. I guess I'll have to put my money where my mouth is and buy that subscription whilst it's on sale :)

Similar Threads

  1. Replies: 0
    Last Post: Jun 16, 2010, 6:18 AM
  2. [CLOSED] Dynamic Panel Creation
    By state in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jul 21, 2009, 2:19 PM
  3. Replies: 0
    Last Post: Apr 30, 2009, 12:55 PM
  4. Dynamic Portal Creation
    By iansriley in forum 1.x Legacy Premium Help
    Replies: 0
    Last Post: Jan 21, 2009, 5:53 PM
  5. Problem with dynamic controls creation
    By afhi in forum 1.x Help
    Replies: 1
    Last Post: Dec 19, 2008, 5:31 PM

Posting Permissions