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 2 1239
This is general mechanism but keep in mind that you have still to do
something that has a meaning. A Form can have childs controls inside this
form but what would be the meaning of having a button "inside" a textbox ?
Use "view source" on your HTML page but eihter this is not processed at all
or ASP.NET renders a button tag inside your input tag but has it has no
meaning the browser might well not render this at all...
--
Patrice
"wASP" <wylbur[at]ev1[dot]net> a écrit dans le message de
news:54********************************@4ax.com... 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
On Tue, 9 Aug 2005 15:06:12 +0200, "Patrice" <no****@nowhere.com> wrote: This is general mechanism but keep in mind that you have still to do something that has a meaning. A Form can have childs controls inside this form but what would be the meaning of having a button "inside" a textbox ?
Use "view source" on your HTML page but eihter this is not processed at all or ASP.NET renders a button tag inside your input tag but has it has no meaning the browser might well not render this at all...
I understand now.
THANKS Patrice!
- wASP This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: ahaideb |
last post by:
I have a table (relation) in my database:
---------------
| parent | child |
---------------
| 1 | 2 |
| 1 | 3 |
| 2 | 4 |
| 2 | 5 ...
|
by: CJack |
last post by:
hy,
I have an mdi application, i create a child form and I want to know
when a button is pressed while that child form is loaded.
I have this code:
private void frmTestBaby_KeyUp(object sender,...
|
by: DavidS |
last post by:
Have parent.aspx from which I open Driver.aspx form via button on parent.aspx. When I first open the modal dialog, the driver.aspx Page_Load function is called. After I close the dialog, then...
|
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: PAUL |
last post by:
Hello,
I have 2 tables with a relationship set up in the dataset with vb
..net. I add a new record to the parent table then edit an existing child
record to have the new parent ID. However when I...
|
by: Scott H. |
last post by:
I have an MDI parent form that creates mdi child forms each of which are
represented by a tab item. I use a third party control to generate the tabbed
MDI child forms.
Each tab or MDI child form...
|
by: Richard Lewis Haggard |
last post by:
What is the mechanism by which a child window can notify its parent that it
has been clicked on?
--
Richard Lewis Haggard
www.Haggard-And-Associates.com
|
by: Phil |
last post by:
I can check for MdiChildren.Length=0, but which event handler should I put
this in to detect when a child window is closed?
TIA
Phil.
|
by: jewel87 |
last post by:
Hi everyone!
I'm writing some code in C under UNIX, which should give some output like this:
PARENT: pid = 10063
CHILD: my pid = 10064
CHILD: my parent's pid = 10063
CHILD: Sleeping...
PARENT:...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |