Init Handler Not Firing After Page_Init

Discussion in 'ASP .Net' started by Wylbur via DotNetMonster.com, Aug 7, 2005.

  1. Hello to all of you geniuses,

    I'm having a problem trying to get an Init handler to fire for a Placeholder
    control
    at the initialization phase. I’ve posted this problem to 3 other ASP.NET
    forums,
    and noone wants to touch it.

    I tried to attach a literal control to a placeholder:
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>

    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    void plc_hldr_Control_Init (object sender, EventArgs e)
    {
    int ndx = 1;

    // Dyn_Control_Placeholder.Controls.Add
    this.Controls.Add
    ( new LiteralControl ("<br>added 1 on init<br>") );
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    void Page_Init (object sender, EventArgs e)
    {
    int ndx = 2;

    // Add a event Handler for 'Init'.

    Dyn_Control_Placeholder.Init
    += new System.EventHandler (plc_hldr_Control_Init);
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ *

    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>



    ... and nothing happened: The Init handler never fired.

    I put my code in the debugger, set a breakpoint on the Init handler
    (plc_hldr_Control_Init), and the breakpoint was never reached.



    I've read the SDK docs, and I thought I had it figured out:
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    .NET Framework Class Library

    Control.Init Event [C#]

    C#
    public event EventHandler Init;

    Event Data
    The event handler receives an argument of type EventArgs.

    Remarks
    Server controls should perform any initialization steps that are required
    to create and set up an instance. You cannot use view-state information
    within this event; it is not populated yet. You should not access another
    server control during this event, regardless of whether it is a child or
    parent to this control. Other server controls are not certain to be created
    and ready for access.

    Example
    [C#] The following example assigns a custom event handler, Control_Init,
    to the Init event of a control, myControl, when the Page_Init method is
    called on the page that contains the control.

    void Page_Init(object sender,EventArgs e)
    {
    // Add a event Handler for 'Init'.
    myControl.Init += new System.EventHandler(Control_Init);
    }

    void Control_Init(object sender,EventArgs e)
    {
    Response.Write("The ID of the object initially : " + myControl.ID);
    // Change the ID property.
    myControl.ID="TestControl";
    Response.Write("<br>The changed ID : " + myControl.ID);
    }

    © 2001-2002 Microsoft Corporation. All rights reserved.

    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>



    One thing I don't understand is: Where did "myControl" come from in the
    given example?



    Just for laughs, I moved the Init functionality into the Page_Init handler:
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    public void plc_hldr_Control_Init (object sender, EventArgs e)
    {
    int ndx = 1;

    // Dyn_Control_Placeholder.Controls.Add
    this.Controls.Add
    ( new LiteralControl("<br>added 1 on init<br>") );
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    public void Page_Init (object sender, EventArgs e)
    {
    int ndx = 2;

    // Add a event Handler for 'Init'.

    // Dyn_Control_Placeholder.Init
    // += new System.EventHandler (plc_hldr_Control_Init);

    // Moving the Init functionality to the Page_Init handler
    Dyn_Control_Placeholder.Controls.Add
    ( new LiteralControl("<br>****** added 1 on init ********<br><br>") );
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>



    ... and it worked as expected.
    ... so the problem has nothing to do with the LiteralControl being attached.


    I'm hoping that someone smarter than me can clue me in on this
    - I would be most grateful.



    My complete code is as follows:
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>

    <%@ Page Language="C#" AutoEventWireup="True" %>

    <html>
    <head>

    <script runat="server">

    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */

    /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    */
    // protected class sys_obj_class
    public class sys_obj_class
    {
    private Page this_page01;
    public Page Get_this_page01
    { get { return this_page01; } }

    private PlaceHolder Obj_Dyn_Ctrl_Placeholder;
    public PlaceHolder Get_Obj_Dyn_Ctrl_Placeholder
    { get { return Obj_Dyn_Ctrl_Placeholder; } }

    private Label Obj_Dyn_Label01;
    public Label Get_Obj_Dyn_Label01
    { get { return Obj_Dyn_Label01; } }


    public sys_obj_class
    (PlaceHolder Dyn_Ctrl_Placeholder, Label Dyn_Label)
    {
    this_page01 = Dyn_Ctrl_Placeholder.Page;
    Obj_Dyn_Ctrl_Placeholder = Dyn_Ctrl_Placeholder;
    Obj_Dyn_Label01 = Dyn_Label;
    }
    }

    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    void plc_hldr_Control_Init (object sender, EventArgs e)
    {
    int ndx = 1;

    // Dyn_Control_Placeholder.Controls.Add
    this.Controls.Add
    ( new LiteralControl("<br>added 1 on init<br>") );
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    void Page_Init (object sender, EventArgs e)
    {
    int ndx = 2;

    // Add a event Handler for 'Init'.

    Dyn_Control_Placeholder.Init
    += new System.EventHandler (plc_hldr_Control_Init);
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */
    protected void Page_Load (Object sender, EventArgs e)
    {
    PlaceHolder plc_hldr = (PlaceHolder) FindControl
    ("Dyn_Control_Placeholder");
    Label lbl_msg01 = (Label) FindControl ("Message01");
    sys_obj_class sys_obj = new sys_obj_class (plc_hldr, lbl_msg01);

    ctrl_pair_creation_01 ccp1 = new ctrl_pair_creation_01 (sys_obj);

    ccp1.create_ctrl_pair_01 ();
    }
    /* ------------------------------------------------------------------ */
    /* ------------------------------------------------------------------ */

    /* - - - - - - - - - - - - - - - - - - - - - - */
    /* - - - - - - - - - - - - - - - - - - - - - - */
    protected class base_create_ctrl_pair
    {
    protected TextBox UserTextBox0x;
    protected Button button0x;
    protected PlaceHolder CCP_Dyn_Ctrl_Placeholder;
    protected Label Dyn_Lbl_msg01;

    /* =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    *
    <<< constructor >>>
    * =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    */
    protected base_create_ctrl_pair (sys_obj_class sys_obj)
    {
    CCP_Dyn_Ctrl_Placeholder = sys_obj.
    Get_Obj_Dyn_Ctrl_Placeholder;
    Dyn_Lbl_msg01 = sys_obj.Get_Obj_Dyn_Label01;
    }
    /* =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    */
    /* =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    */

    private TextBox create_text_box_control (String text_box_id)
    { // Create UserTextBox TextBox control.
    TextBox new_TextBox = new TextBox ();

    // Configure the UserTextBox TextBox control.
    new_TextBox.ID = text_box_id;

    // Add UserTextBox TextBox control to the Controls collection
    // of the Dyn_Control_Placeholder PlaceHolder control.
    CCP_Dyn_Ctrl_Placeholder.Controls.Add (new_TextBox);
    CCP_Dyn_Ctrl_Placeholder.Controls.Add
    ( new LiteralControl("<br><br>") );

    return new_TextBox;
    }

    /* --------------------------------------------------------- *
    Example: The following example creates a Button,
    sets its DialogResult property to DialogResult.OK,
    and adds it to a Form.
    * --------------------------------------------------------- */
    private void Create_new_button (String Btn_ID, String Btn_text)
    { // Create and initialize a Button.
    button0x = new Button();
    button0x.ID = Btn_ID;
    button0x.Text = Btn_text;

    CCP_Dyn_Ctrl_Placeholder.Controls.Add (button0x);
    CCP_Dyn_Ctrl_Placeholder.Controls.Add
    ( new LiteralControl("<br>===================<br><br>") );
    }

    protected void init_single_line_text_box (TextBox new_TextBox, int
    col_sz)
    { new_TextBox.Columns = col_sz; }

    protected void create_ctrl_pair_0x
    (String TB_ID, String DB_ID, String DB_txt)
    { // Create UserTextBox TextBox control.
    UserTextBox0x = create_text_box_control (TB_ID);
    Create_new_button(DB_ID, DB_txt);
    }

    /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    +- *
    <<< Button Click Handlers >>>
    * -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    +- */
    private String submit_click_str01 = "The TextBox";

    private String submit_click_str02
    = " control above is dynamically generated. <br> You
    entered: ";

    public void Submit_Click (Object sender, EventArgs e)
    { // Retrieve the UserTextBox TextBox control from the
    Dyn_Control_Placeholder
    // PlaceHolder control.
    TextBox TempTextBox = (TextBox) CCP_Dyn_Ctrl_Placeholder.
    FindControl("UserTextBox1");

    // Display the Text property.
    Dyn_Lbl_msg01.Text = submit_click_str01 + '1' +
    submit_click_str02 + TempTextBox.Text;
    }
    /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    +- */
    /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    +- */

    }
    /* - - - - - - - - - - - - - - - - - - - - - - */
    /* - - - - - - - - - - - - - - - - - - - - - - */

    protected class ctrl_pair_creation_01 : base_create_ctrl_pair
    {
    private sys_obj_class lcl_sys_obj;

    // constructor
    public ctrl_pair_creation_01 (sys_obj_class sys_obj) : base
    (sys_obj)
    { lcl_sys_obj = sys_obj; }

    /* . . . . . . . . . . . . . */
    public void create_ctrl_pair_01 ()
    { create_ctrl_pair_0x
    ("UserTextBox1", "DButton01", "Submit 01");

    button0x.Click += new EventHandler (Submit_Click);

    if (!lcl_sys_obj.Get_this_page01.IsPostBack)
    init_single_line_text_box (UserTextBox0x, 22);
    }
    /* . . . . . . . . . . . . . */
    }
    /* - - - - - - - - - - - - - - - - - - - - - - */
    /* - - - - - - - - - - - - - - - - - - - - - - */
    /* - - - - - - - - - - - - - - - - - - - - - - */

    </script>
    </head>

    <body>

    <form runat="server">

    <h3> Control Init </h3>

    Enter some text and click the Submit button. <br><br>

    <asp:placeHolder ID="Dyn_Control_Placeholder" runat="server"/>

    <asp:Label ID="Message01" runat="server"/>

    </form>

    </body>
    </html>

    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>
    <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>



    THANKS IN ADVANCE!!!


    Wylbur
    =======================
     
    Wylbur via DotNetMonster.com, Aug 7, 2005
    #1
    1. Advertising

  2. Wylbur via DotNetMonster.com

    Brock Allen Guest

    Try wiring up the Init for the Placeholder via the <asp:placeholder OnInit="YourEventHandler">
    syntax.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hello to all of you geniuses,
    >
    > I'm having a problem trying to get an Init handler to fire for a
    > Placeholder
    > control
    > at the initialization phase. I’ve posted this problem to 3 other
    > ASP.NET
    > forums,
    > and noone wants to touch it.
    > I tried to attach a literal control to a placeholder:
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > void plc_hldr_Control_Init (object sender, EventArgs e)
    > {
    > int ndx = 1;
    > // Dyn_Control_Placeholder.Controls.Add
    > this.Controls.Add
    > ( new LiteralControl ("<br>added 1 on init<br>") );
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > void Page_Init (object sender, EventArgs e)
    > {
    > int ndx = 2;
    > // Add a event Handler for 'Init'.
    >
    > Dyn_Control_Placeholder.Init
    > += new System.EventHandler (plc_hldr_Control_Init);
    > }
    > /* ------------------------------------------------------------------
    > */ /*
    > ------------------------------------------------------------------ *
    >
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > ... and nothing happened: The Init handler never fired.
    >
    > I put my code in the debugger, set a breakpoint on the Init handler
    > (plc_hldr_Control_Init), and the breakpoint was never reached.
    >
    > I've read the SDK docs, and I thought I had it figured out:
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > .NET Framework Class Library
    > Control.Init Event [C#]
    >
    > C#
    > public event EventHandler Init;
    > Event Data
    > The event handler receives an argument of type EventArgs.
    > Remarks
    > Server controls should perform any initialization steps that are
    > required
    > to create and set up an instance. You cannot use view-state
    > information
    > within this event; it is not populated yet. You should not access
    > another
    > server control during this event, regardless of whether it is a child
    > or
    > parent to this control. Other server controls are not certain to be
    > created
    > and ready for access.
    > Example
    > [C#] The following example assigns a custom event handler,
    > Control_Init,
    > to the Init event of a control, myControl, when the Page_Init method
    > is
    > called on the page that contains the control.
    > void Page_Init(object sender,EventArgs e)
    > {
    > // Add a event Handler for 'Init'.
    > myControl.Init += new System.EventHandler(Control_Init);
    > }
    > void Control_Init(object sender,EventArgs e)
    > {
    > Response.Write("The ID of the object initially : " + myControl.ID);
    > // Change the ID property.
    > myControl.ID="TestControl";
    > Response.Write("<br>The changed ID : " + myControl.ID);
    > }
    > © 2001-2002 Microsoft Corporation. All rights reserved.
    >
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > One thing I don't understand is: Where did "myControl" come from in
    > the given example?
    >
    > Just for laughs, I moved the Init functionality into the Page_Init
    > handler:
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > public void plc_hldr_Control_Init (object sender, EventArgs e)
    > {
    > int ndx = 1;
    > // Dyn_Control_Placeholder.Controls.Add
    > this.Controls.Add
    > ( new LiteralControl("<br>added 1 on init<br>") );
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > public void Page_Init (object sender, EventArgs e)
    > {
    > int ndx = 2;
    > // Add a event Handler for 'Init'.
    >
    > // Dyn_Control_Placeholder.Init
    > // += new System.EventHandler (plc_hldr_Control_Init);
    > // Moving the Init functionality to the Page_Init handler
    > Dyn_Control_Placeholder.Controls.Add
    > ( new LiteralControl("<br>****** added 1 on init
    > ********<br><br>") );
    > }
    > /* ------------------------------------------------------------------
    > */ /*
    > ------------------------------------------------------------------ */
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > ... and it worked as expected.
    > ... so the problem has nothing to do with the LiteralControl being
    > attached.
    > I'm hoping that someone smarter than me can clue me in on this
    > - I would be most grateful.
    > My complete code is as follows:
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > <%@ Page Language="C#" AutoEventWireup="True" %>
    >
    > <html> <head>
    >
    > <script runat="server">
    >
    > /* ------------------------------------------------------------------
    > */ /*
    > ------------------------------------------------------------------ */
    >
    > /*
    > -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    > // protected class sys_obj_class
    > public class sys_obj_class
    > {
    > private Page this_page01;
    > public Page Get_this_page01
    > { get { return this_page01; } }
    > private PlaceHolder Obj_Dyn_Ctrl_Placeholder;
    > public PlaceHolder Get_Obj_Dyn_Ctrl_Placeholder
    > { get { return Obj_Dyn_Ctrl_Placeholder; } }
    > private Label Obj_Dyn_Label01;
    > public Label Get_Obj_Dyn_Label01
    > { get { return Obj_Dyn_Label01; } }
    > public sys_obj_class
    > (PlaceHolder Dyn_Ctrl_Placeholder, Label Dyn_Label)
    > {
    > this_page01 = Dyn_Ctrl_Placeholder.Page;
    > Obj_Dyn_Ctrl_Placeholder = Dyn_Ctrl_Placeholder;
    > Obj_Dyn_Label01 = Dyn_Label;
    > }
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > void plc_hldr_Control_Init (object sender, EventArgs e)
    > {
    > int ndx = 1;
    > // Dyn_Control_Placeholder.Controls.Add
    > this.Controls.Add
    > ( new LiteralControl("<br>added 1 on init<br>") );
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > void Page_Init (object sender, EventArgs e)
    > {
    > int ndx = 2;
    > // Add a event Handler for 'Init'.
    >
    > Dyn_Control_Placeholder.Init
    > += new System.EventHandler (plc_hldr_Control_Init);
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    > protected void Page_Load (Object sender, EventArgs e)
    > {
    > PlaceHolder plc_hldr = (PlaceHolder) FindControl
    > ("Dyn_Control_Placeholder");
    > Label lbl_msg01 = (Label) FindControl ("Message01");
    > sys_obj_class sys_obj = new sys_obj_class (plc_hldr,
    > lbl_msg01);
    > ctrl_pair_creation_01 ccp1 = new ctrl_pair_creation_01
    > (sys_obj);
    >
    > ccp1.create_ctrl_pair_01 ();
    > }
    > /* ------------------------------------------------------------------
    > */
    > /* ------------------------------------------------------------------
    > */
    >
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > protected class base_create_ctrl_pair
    > {
    > protected TextBox UserTextBox0x;
    > protected Button button0x;
    > protected PlaceHolder CCP_Dyn_Ctrl_Placeholder;
    > protected Label Dyn_Lbl_msg01;
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    > *
    > <<< constructor >>>
    > *
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    > */
    > protected base_create_ctrl_pair (sys_obj_class sys_obj)
    > {
    > CCP_Dyn_Ctrl_Placeholder = sys_obj.
    > Get_Obj_Dyn_Ctrl_Placeholder;
    > Dyn_Lbl_msg01 = sys_obj.Get_Obj_Dyn_Label01;
    > }
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    > */
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=
    > */
    > private TextBox create_text_box_control (String text_box_id)
    > { // Create UserTextBox TextBox control.
    > TextBox new_TextBox = new TextBox ();
    > // Configure the UserTextBox TextBox control.
    > new_TextBox.ID = text_box_id;
    > // Add UserTextBox TextBox control to the Controls
    > collection
    > // of the Dyn_Control_Placeholder PlaceHolder control.
    > CCP_Dyn_Ctrl_Placeholder.Controls.Add (new_TextBox);
    > CCP_Dyn_Ctrl_Placeholder.Controls.Add
    > ( new LiteralControl("<br><br>") );
    > return new_TextBox;
    > }
    > /* ---------------------------------------------------------
    > *
    > Example: The following example creates a Button,
    > sets its DialogResult property to DialogResult.OK,
    > and adds it to a Form.
    > * ---------------------------------------------------------
    > */
    > private void Create_new_button (String Btn_ID, String
    > Btn_text)
    > { // Create and initialize a Button.
    > button0x = new Button();
    > button0x.ID = Btn_ID;
    > button0x.Text = Btn_text;
    > CCP_Dyn_Ctrl_Placeholder.Controls.Add (button0x);
    > CCP_Dyn_Ctrl_Placeholder.Controls.Add
    > ( new LiteralControl("<br>===================<br><br>")
    > );
    > }
    > protected void init_single_line_text_box (TextBox
    > new_TextBox, int
    > col_sz)
    > { new_TextBox.Columns = col_sz; }
    > protected void create_ctrl_pair_0x
    > (String TB_ID, String DB_ID, String DB_txt)
    > { // Create UserTextBox TextBox control.
    > UserTextBox0x = create_text_box_control (TB_ID);
    > Create_new_button(DB_ID, DB_txt);
    > }
    > /*
    > -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > +- *
    > <<< Button Click Handlers >>>
    > *
    > -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > +- */
    > private String submit_click_str01 = "The TextBox";
    > private String submit_click_str02
    > = " control above is dynamically generated. <br>
    > You
    > entered: ";
    > public void Submit_Click (Object sender, EventArgs e)
    > { // Retrieve the UserTextBox TextBox control from the
    > Dyn_Control_Placeholder
    > // PlaceHolder control.
    > TextBox TempTextBox = (TextBox) CCP_Dyn_Ctrl_Placeholder.
    > FindControl("UserTextBox1");
    > // Display the Text property.
    > Dyn_Lbl_msg01.Text = submit_click_str01 + '1' +
    > submit_click_str02 + TempTextBox.Text;
    > }
    > /*
    > -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > +- */
    > /*
    > -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > +- */
    > }
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > protected class ctrl_pair_creation_01 : base_create_ctrl_pair
    > {
    > private sys_obj_class lcl_sys_obj;
    > // constructor
    > public ctrl_pair_creation_01 (sys_obj_class sys_obj) : base
    > (sys_obj)
    > { lcl_sys_obj = sys_obj; }
    > /* . . . . . . . . . . . . . */
    > public void create_ctrl_pair_01 ()
    > { create_ctrl_pair_0x
    > ("UserTextBox1", "DButton01", "Submit 01");
    > button0x.Click += new EventHandler (Submit_Click);
    >
    > if (!lcl_sys_obj.Get_this_page01.IsPostBack)
    > init_single_line_text_box (UserTextBox0x, 22);
    > }
    > /* . . . . . . . . . . . . . */
    > }
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > </script>
    > </head>
    > <body>
    >
    > <form runat="server">
    >
    > <h3> Control Init </h3>
    >
    > Enter some text and click the Submit button. <br><br>
    >
    > <asp:placeHolder ID="Dyn_Control_Placeholder" runat="server"/>
    >
    > <asp:Label ID="Message01" runat="server"/>
    >
    > </form>
    >
    > </body>
    > </html>
    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    > <[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]>-<[+]
    > >

    >
    > THANKS IN ADVANCE!!!
    >
    > Wylbur
    > =======================
     
    Brock Allen, Aug 7, 2005
    #2
    1. Advertising

  3. Hi Brock,

    I did that, and it worked: I got the Init function to fire.

    OK - so now I need to figure out why I can't get it to work from the
    Page_Init method.

    I hope you have an idea.


    Thanks,

    Wylbur
    ============================

    Brock Allen wrote:
    >Try wiring up the Init for the Placeholder via the <asp:placeholder OnInit="YourEventHandler">
    >syntax.
    >
    >-Brock
    >DevelopMentor
    >http://staff.develop.com/ballen
    >
    >> Hello to all of you geniuses,
    >>

    >[quoted text clipped - 370 lines]
    >> Wylbur
    >> =======================



    --
    Message posted via http://www.dotnetmonster.com
     
    Wylbur via DotNetMonster.com, Aug 7, 2005
    #3
  4. Wylbur via DotNetMonster.com

    Brock Allen Guest

    Because Child controls' Init is called before the parent control's Init (in
    this case, the page).

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi Brock,
    >
    > I did that, and it worked: I got the Init function to fire.
    >
    > OK - so now I need to figure out why I can't get it to work from the
    > Page_Init method.
    >
    > I hope you have an idea.
    >
    > Thanks,
    >
    > Wylbur
    > ============================
    > Brock Allen wrote:
    >
    >> Try wiring up the Init for the Placeholder via the <asp:placeholder
    >> OnInit="YourEventHandler"> syntax.
    >>
    >> -Brock
    >> DevelopMentor
    >> http://staff.develop.com/ballen
    >>> Hello to all of you geniuses,
    >>>

    >> [quoted text clipped - 370 lines]
    >>
    >>> Wylbur
    >>> =======================
     
    Brock Allen, Aug 7, 2005
    #4
  5. Dang.

    Then that means that I need to load the child Init
    handler before Page_Init is called?

    Do you have any idea as to how I can do that?

    I don't understand this: I pretty much copied the code
    from the example given in the SDK docs.

    DANG again!

    Wylbur
    =================

    Brock Allen wrote:
    >Because Child controls' Init is called before the parent control's Init (in
    >this case, the page).
    >
    >-Brock
    >DevelopMentor
    >http://staff.develop.com/ballen
    >
    >> Hi Brock,
    >>

    >[quoted text clipped - 22 lines]
    >>>> Wylbur
    >>>> =======================



    --
    Message posted via http://www.dotnetmonster.com
     
    Wylbur via DotNetMonster.com, Aug 7, 2005
    #5
  6. Wylbur via DotNetMonster.com

    Brock Allen Guest

    > Then that means that I need to load the child Init handler before
    > Page_Init is called?
    >
    > Do you have any idea as to how I can do that?


    You can do it the way I showed you -- declaratively in the ASPX. What is
    it you need to do from the page that has to happen when the child control
    is initialized?

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
     
    Brock Allen, Aug 8, 2005
    #6
  7. Brock Allen wrote:
    >> Then that means that I need to load the child Init handler before
    >> Page_Init is called?
    >>
    >> Do you have any idea as to how I can do that?

    >
    >You can do it the way I showed you -- declaratively in the ASPX. What is
    >it you need to do from the page that has to happen when the child control
    >is initialized?


    If I'm chaining dynamic controls to other dynamic controls on successive
    postbacks, then it’s not going to be a simple matter of using Init handlers
    called from static tags. I’ve been going over several online documents
    - including these:

    http://aspalliance.com/63

    http://aspalliance.com/520

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspnet/html/asp12282000.asp


    ... and I’m thinking I can store objects for creating those controls
    in the session state (it seems to be the only thing that persists from
    one request/response cycle to another and unique to a particular session).
    I’ll have to do some more research on the matter before I can devise
    a more concrete approach to this - I still have a lot to learn.

    In any case, I very much appreciate your efforts to set me straight on this.
    You’ve made me realize that my initial plan is unworkable - so it’s back
    to the proverbial drawing board.


    THANKS AGAIN Brock!


    Wylbur
    ========================


    --
    Message posted via http://www.dotnetmonster.com
     
    Wylbur via DotNetMonster.com, Aug 8, 2005
    #7
  8. Wylbur via DotNetMonster.com

    Brock Allen Guest

    > If I'm chaining dynamic controls to other dynamic controls on
    > successive
    > postbacks, then it’s not going to be a simple matter of using Init
    > handlers
    > called from static tags.


    What exactly are you doing -- do you mean that you're dynamically creating
    the controls? If so, then it's easy to get the Init event. Once you create
    the control but before you add it into the controls collection setup your
    event handler.

    > ... and I’m thinking I can store objects for creating those controls
    > in the session state (it seems to be the only thing that persists from
    > one request/response cycle to another and unique to a particular
    > session).


    It sounds like you're saying you want to store the actual control in Session
    -- I'd strongly advise against that. The model for ASP.NET is to recreate
    the page and all server side controls for each request. Caching a control
    in session might have adverse effetcs.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen
     
    Brock Allen, Aug 8, 2005
    #8
  9. Brock Allen wrote:
    >> If I'm chaining dynamic controls to other dynamic controls on
    >> successive
    >> postbacks, then it?s not going to be a simple matter of using Init
    >> handlers
    >> called from static tags.

    >
    >What exactly are you doing -- do you mean that you're dynamically creating
    >the controls?


    Yes - and, after reading the docs by Scott Mitchell, I realize that
    I need to reconstitute any dynamically-created control hierarchy
    before the viewstate gets loaded - in Page_Init if no place else.


    > If so, then it's easy to get the Init event. Once you create
    >the control but before you add it into the controls collection setup your
    >event handler.


    OK - understood.


    >> ... and I?m thinking I can store objects for creating those controls
    >> in the session state (it seems to be the only thing that persists from
    >> one request/response cycle to another and unique to a particular
    >> session).

    >
    >It sounds like you're saying you want to store the actual control in Session
    >-- I'd strongly advise against that.


    Not exactly - what I have in mind is to store an hierarchical structure
    in Session containing references to the methods that would be needed
    to recreate the dynamically-created controls - sort of like a “blueprint”
    for lack of a better term. I have a vague idea as to how to approach this,
    but I haven’t fully fleshed it out as of yet.

    ... or maybe I should use the ViewState instead - I don’t know why not.

    By my own admission, I’ve still got a lot to learn - and that’s the point
    behind doing this: The best way to learn how to do something is to do it
    - roll your sleeves up and get your hands dirty. With the help of yourself
    and others in these tech forums, I’ve made substantial progress - I’m
    starting
    to get a grasp on the fundamentals involved. Eventually, I plan to pull
    the basic elements/concepts from this toy and use it to create the
    adaptive/reactive webpages that I plan to develop in the future.

    ... but one thing at a time.

    I’ve encountered a bit of a snag in chaining a child control (Button control)
    onto a TextBox control (in it’s control collection). When I did that, the
    button
    was never rendered - it rendered OK when it was attached to the placeholder
    (added after the textbox) - but not when it was a child to the TextBox.

    I posted this problem to a Microsoft NNTP forum on usenet
    (microsoft.public.dotnet.framework.aspnet),
    and Bruce Barker clued me in on this:
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    not quite. the page renders all its children. if the one of the form
    controls supports children of its own, it renders them.

    the default implemenation of Render is RenderChildren. the TextBox overrides
    the render with its own, and never calls RenderChildren (because the TextBox
    does not support children).

    -- bruce (sqlwork.com)



    "wASP" <wylbur[at]ev1[dottt]net> wrote in message
    news:...
    >
    > Hi,
    >
    > I was under the impression that, when ASP rendered a page,
    > it recursively traversed the hierarchy, executing all controls
    > in each ControlCollection of every control in that hierarchy.
    >
    > I tried adding a Button control to a TextBox ControlCollection,
    > and it didn't execute. When I add the control to the Placeholder
    > ControlCollection (after the TextBox control is added), it executes
    > without any problem:
    > /* . . . . . . . . . . . . . . . . */
    > protected void create_ctrl_pair_0x
    > (String text_box_id, String Btn_ID, String Btn_text)
    > {
    > ControlCollection crnt_ctrl = CCP_Dyn_Ctrl_Placeholder.Controls;
    >
    > // Create UserTextBox TextBox control.
    >
    > UserTextBox0x = new TextBox ();
    >
    > // Configure the UserTextBox TextBox control.
    > UserTextBox0x.ID = text_box_id;
    >
    > // Add UserTextBox TextBox control to the Controls collection
    > // of the Dyn_Control_Placeholder PlaceHolder control.
    >
    > crnt_ctrl.Add (UserTextBox0x);
    > crnt_ctrl.Add ( new
    > LiteralControl("<br>XxXxXxXxXxXxXxXxX<br><br>") );
    >
    > // Create and initialize a Button.
    >
    > button0x = new Button();
    > button0x.ID = Btn_ID;
    > button0x.Text = Btn_text;
    >
    > // make the button a child of the text box control.
    > crnt_ctrl = UserTextBox0x.Controls;
    >
    > crnt_ctrl.Add (button0x);
    > crnt_ctrl.Add
    > ( new LiteralControl("<br>===================<br><br>") );
    > }
    > /* . . . . . . . . . . . . . . . . */
    > /* | | | | | | | | | | | | | | | | */
    > /* . . . . . . . . . . . . . . . . */
    >
    >
    >
    > If this assignment statement is removed from the above:
    > crnt_ctrl = UserTextBox0x.Controls;
    > ... it works fine. Otherwise, there is no button, as the child is
    > neglected.
    >
    >
    >
    > Can anyone give me an idea as to what I would have to do to make this
    > work?
    >
    >
    >
    > My complete code is as follows:
    > <+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>
    > <+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>
    > <%@ Page Language="C#" AutoEventWireup="True" %>
    >
    > <html>
    > <head>
    >
    > <script runat="server">
    >
    > /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    > /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    > // protected class sys_obj_class
    > public class sys_obj_class
    > {
    > private Page this_page01;
    > public Page Get_this_page01
    > { get { return this_page01; } }
    >
    > private PlaceHolder Obj_Dyn_Ctrl_Placeholder;
    > public PlaceHolder Get_Obj_Dyn_Ctrl_Placeholder
    > { get { return Obj_Dyn_Ctrl_Placeholder; } }
    >
    > private Label Obj_Dyn_Label01;
    > public Label Get_Obj_Dyn_Label01
    > { get { return Obj_Dyn_Label01; } }
    >
    >
    > public sys_obj_class
    > (PlaceHolder Dyn_Ctrl_Placeholder, Label Dyn_Label)
    > {
    > this_page01 = Dyn_Ctrl_Placeholder.Page;
    > Obj_Dyn_Ctrl_Placeholder = Dyn_Ctrl_Placeholder;
    > Obj_Dyn_Label01 = Dyn_Label;
    > }
    > }
    >
    > /* ------------------------------------------------------------------ */
    > /* ------------------------------------------------------------------ */
    > public void Page_Init (object sender, EventArgs e)
    > {
    > int ndx = 2;
    >
    > Dyn_Control_Placeholder.Controls.Add
    > ( new LiteralControl("<br>||| added 1 on init |||<br><br>") );
    > }
    > /* ------------------------------------------------------------------ */
    > /* ------------------------------------------------------------------ */
    > protected void Page_Load (Object sender, EventArgs e)
    > {
    > PlaceHolder plc_hldr = (PlaceHolder) FindControl
    > ("Dyn_Control_Placeholder");
    > Label lbl_msg01 = (Label) FindControl ("Message01");
    > sys_obj_class sys_obj = new sys_obj_class (plc_hldr, lbl_msg01);
    >
    > ctrl_pair_creation_01 ccp1 = new ctrl_pair_creation_01 (sys_obj);
    >
    > ccp1.create_ctrl_pair_01 ();
    > }
    > /* ------------------------------------------------------------------ */
    > /* ------------------------------------------------------------------ */
    >
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > protected class base_create_ctrl_pair
    > {
    > protected TextBox UserTextBox0x;
    > protected Button button0x;
    > protected PlaceHolder CCP_Dyn_Ctrl_Placeholder;
    > protected Label Dyn_Lbl_msg01;
    >
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#= *
    > <<< constructor >>>
    > *
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#= */
    > protected base_create_ctrl_pair (sys_obj_class sys_obj)
    > {
    > CCP_Dyn_Ctrl_Placeholder =
    > sys_obj.Get_Obj_Dyn_Ctrl_Placeholder;
    > Dyn_Lbl_msg01 = sys_obj.Get_Obj_Dyn_Label01;
    > }
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#= */
    > /*
    > =#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#=#= */
    >
    > protected void init_single_line_text_box (TextBox new_TextBox,
    > int col_sz)
    > { new_TextBox.Columns = col_sz; }
    >
    > /* . . . . . . . . . . . . . . . .
    > */
    > protected void create_ctrl_pair_0x
    > (String text_box_id, String Btn_ID, String Btn_text)
    > {
    > ControlCollection crnt_ctrl =
    > CCP_Dyn_Ctrl_Placeholder.Controls;
    >
    > // Create UserTextBox TextBox control.
    >
    > UserTextBox0x = new TextBox ();
    >
    > // Configure the UserTextBox TextBox control.
    > UserTextBox0x.ID = text_box_id;
    >
    > // Add UserTextBox TextBox control to the Controls collection
    > // of the Dyn_Control_Placeholder PlaceHolder control.
    >
    > crnt_ctrl.Add (UserTextBox0x);
    > crnt_ctrl.Add ( new
    > LiteralControl("<br>XxXxXxXxXxXxXxXxX<br><br>") );
    >
    > // Create and initialize a Button.
    >
    > button0x = new Button();
    > button0x.ID = Btn_ID;
    > button0x.Text = Btn_text;
    >
    > // make the button a child of the text box control.
    > crnt_ctrl = UserTextBox0x.Controls;
    >
    > crnt_ctrl.Add (button0x);
    > crnt_ctrl.Add
    > ( new
    > LiteralControl("<br>===================::::<br><br>") );
    > }
    > /* . . . . . . . . . . . . . . . .
    > */
    >
    >
    >
    > /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > *
    > <<< Button Click Handlers >>>
    >
    > * -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    > private String submit_click_str01 = "The TextBox";
    >
    > private String submit_click_str02
    > = " control above is dynamically generated. <br> You
    > entered: ";
    >
    > public void Submit_Click (Object sender, EventArgs e)
    > { // Retrieve the UserTextBox TextBox control from the
    > Dyn_Control_Placeholder
    > // PlaceHolder control.
    > TextBox TempTextBox = (TextBox)
    > CCP_Dyn_Ctrl_Placeholder.FindControl("UserTextBox1");
    >
    > // Display the Text property.
    > Dyn_Lbl_msg01.Text = submit_click_str01 + '1' +
    > submit_click_str02 +
    > TempTextBox.Text;
    > }
    >
    > /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    >
    > /* -+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
    > */
    >
    > }
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    > /* END: protected class base_create_ctrl_pair */
    > /* - - - - - - - - - - - - - - - - - - - - - - */
    >
    > /* /|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\ */
    > protected class ctrl_pair_creation_01 : base_create_ctrl_pair
    > {
    > private sys_obj_class lcl_sys_obj;
    >
    > // constructor
    > public ctrl_pair_creation_01 (sys_obj_class sys_obj) : base
    > (sys_obj)
    > { lcl_sys_obj = sys_obj; }
    >
    > /* . . . . . . . . . . . . . */
    > public void create_ctrl_pair_01 ()
    > { create_ctrl_pair_0x
    > ("UserTextBox1", "DButton01", "Submit 01");
    >
    > button0x.Click += new EventHandler (Submit_Click);
    >
    > if (!lcl_sys_obj.Get_this_page01.IsPostBack)
    > init_single_line_text_box (UserTextBox0x, 22);
    > }
    > /* . . . . . . . . . . . . . */
    > }
    > /* /|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\ */
    > /* /|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\_/|\ */
    >
    > </script>
    > </head>
    >
    > <body>
    >
    > <form runat="server">
    >
    > <h3> Control Init </h3>
    >
    > Enter some text and click the Submit button. <br><br>
    >
    > <asp:placeHolder ID="Dyn_Control_Placeholder" runat="server"/>
    >
    > <asp:Label ID="Message01" runat="server"/>
    >
    > </form>
    >
    > </body>
    > </html>
    >
    > <+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>
    > <+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>-<+>
    >
    >
    >
    > THANKS!!!
    >
    >
    >
    > - wASP

    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/

    \\\ ///
    \\\ ///
    \\\ ///
    \\\ ///
    \\\ ///
    \\\ ///
    \\\ ///
    \\\ ///
    \\\///
    \\//
    \/

    I suppose this doesn’t really HAVE to be a problem (I could always just
    add the controls to the placeholder after the textbox), but if there is
    a simple solution to this, I would like to know what it is.

    As I stated before: I’m still very much in the learning phase in all of this.



    I was reviewing the SDK docs ...
    ms-help://MS.NETFrameworkSDKv1.
    1/cpref/html/frlrfsystemwebuicontrolclassrenderchildrentopic.htm
    ... and it seems that I can override the ChildRender method
    ... though I don’t fully understand the example given:
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\
    .NET Framework Class Library

    Control.RenderChildren Method

    Outputs the content of a server control's children to a provided
    HtmlTextWriter object, which writes the content to be rendered
    on the client.


    [C#]
    protected virtual void RenderChildren(HtmlTextWriter writer);

    writer
    The HtmlTextWriter object that receives the rendered content.

    Remarks
    This method notifies ASP.NET to render any Active Server Pages (ASP)
    code on the page. If no ASP code exists on the page, this method
    renders any child controls for the server control.

    Example
    The following example overrides the RenderChildren method in
    a custom server control. It determines whether the current control
    has any child controls in its ControlCollection object. If it does,
    it uses the Count property to iterate through the collection.
    As it encounters each child control, it uses the RenderControl
    method to render the parent control, and all of its child controls,
    to the containing page.

    The overridden Render method then calls the overridden RenderChildren method.

    [C#]
    // Override default implementation to Render children according to needs.
    protected override void RenderChildren (HtmlTextWriter output)
    {
    if (HasControls())
    {
    // Render Children in reverse order.
    for(int i = Controls.Count - 1; i >= 0; --i)
    {
    Controls.RenderControl(output);
    }
    }
    }

    protected override void Render (HtmlTextWriter output)
    {
    output.Write("<br>Message from Control : " + Message);
    output.Write("Showing Custom controls created in reverse" +
    "order");
    // Render Controls.
    RenderChildren(output);
    }

    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/
    \/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/



    > The model for ASP.NET is to recreate
    >the page and all server side controls for each request.


    That’s what I’m after - my objective at this point.


    > Caching a control in session might have adverse effects.


    I’ll be sure to keep that in mind.

    THANKS Brock!


    Wylbur
    ======================
     
    Wylbur via DotNetMonster.com, Aug 9, 2005
    #9
  10. wASP = Wylbur

    I'm known as wASP on usenet, BTW.

    Sorry for any confusion that I might have caused.
    ==============================================

    wASP wrote:
    >UPDATE: The issue WRT placing the button control as a child to the
    >textbox control has been resolved. The basic problem was that
    >I didn't understand the implications of making the button a child control
    >of the textbox - until rl just now clued me in with his post in another
    >thread ("Child Neglect").
    >
    >It was actually a "good" mistake to make, as it contributed to
    >my understanding as to the functioning of ASP.
    >
    >I'm getting my hands dirty, and it's paying off.
    >
    >Obviously, I'm new to the whole ASP.NET paradigm, and, right now,
    >I'm just flopping around like a fish out of water; I'm taking my
    >lumps and bruises in the learning process. I don't have any good
    >references for spelling out how to create and manipulate dynamic controls,
    >so I'm depending on techs like yourself to give me a clue.
    >
    >I greatly appreciate it.
    >
    >Also, I just now realized that the netmonster forum is actually
    >an NNTP site on usenet - as I am now posting to with my newsreader.
    >
    >Ya' learn sumtin' new ev'ry day.
    >
    >- wASP



    --
    Message posted via DotNetMonster.com
    http://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/200508/1
     
    Wylbur via DotNetMonster.com, Aug 9, 2005
    #10
  11. Wylbur via DotNetMonster.com

    wASP Guest

    UPDATE: The issue WRT placing the button control as a child to the
    textbox control has been resolved. The basic problem was that
    I didn't understand the implications of making the button a child control
    of the textbox - until rl just now clued me in with his post in another
    thread ("Child Neglect").

    It was actually a "good" mistake to make, as it contributed to
    my understanding as to the functioning of ASP.

    I'm getting my hands dirty, and it's paying off.

    Obviously, I'm new to the whole ASP.NET paradigm, and, right now,
    I'm just flopping around like a fish out of water; I'm taking my
    lumps and bruises in the learning process. I don't have any good
    references for spelling out how to create and manipulate dynamic controls,
    so I'm depending on techs like yourself to give me a clue.

    I greatly appreciate it.

    Also, I just now realized that the netmonster forum is actually
    an NNTP site on usenet - as I am now posting to with my newsreader.

    Ya' learn sumtin' new ev'ry day.

    - wASP
     
    wASP, Aug 9, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Craig Buchanan

    ViewState not available on Page_Init?

    Craig Buchanan, Feb 20, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    11,225
    Kevin Spencer
    Feb 20, 2004
  2. Tony Cheng
    Replies:
    1
    Views:
    8,318
    Juan T. Llibre
    Feb 24, 2006
  3. Replies:
    1
    Views:
    696
    Jules
    Aug 18, 2005
  4. Jess
    Replies:
    4
    Views:
    471
  5. news.aon.at
    Replies:
    11
    Views:
    678
    Ian Collins
    Jan 29, 2011
Loading...

Share This Page