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 1 905
To anyone who is interested, this issue has been resolved: Case closed.
Thanks,
-wASP
================================
On Mon, 08 Aug 2005 12:36:00 -0500, wASP <wylbur[at]ev1[dot]net> wrote: 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("UserTextBox 1");
// 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
- wASP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: wASP |
last post by:
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...
|
by: wASP |
last post by:
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...
|
by: Charles Law |
last post by:
For some reason, when I click the X to close my MDI parent form, the action
appears to be re-directed to one of the MDI child forms, and the parent
remains open. I am then unable to close the...
|
by: wASP |
last post by:
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |