i have a dynamically created user control which contains a non-dynamically
created ASP.Net button. When the button is clicked, the event is not fired.
I know that the control must be created on postback, and it is. However,
I've noticed an intriguing thing which I think might be at the root of the
problem.
My page inherits from a basepage, which in turn inherits from
System.Web.UI.Page. On initial load, the events fire something like this:
page.load (aspx page)
control.load (dynamically loaded ascx control)
base.CreateChildControls (base page)
base.Render (base page)
however, on postback, the sequence of events changes to:
base.CreateChildControls
page.load
control.load
base.Render
I imagine that this unexpected change of sequence, in addition to what I'm
probably doing in CreateChildControls is the cause of my problem. I'm
guessing this because if I make my page inherit directly from
System.Web.UI.Page, the problem is solved (also, if I don't make the control
dynamic, the problem is solved).
Here's my CreateChildControls in the base page, as I suspect I might be
doing something wrong in it:
Protected Overrides Sub CreateChildControls()
Me.Controls.Add(_plcContent)
Dim mainForm As HtmlForm = CType(Page.FindControl("frmMain"), HtmlForm)
If Not mainForm Is Nothing Then
Dim Header As Control =
CType(Page.LoadControl("~/Presentation/Header.ascx"), Control)
Dim Footer As Control =
CType(Page.LoadControl("~/Presentation/Footer.ascx"), Control)
mainForm.Controls.AddAt(0, Header)
mainForm.Controls.Add(Footer)
_plcContent.Controls.Add(mainForm)
End If
MyBase.CreateChildControls()
End Sub
_plcContent is a new PlaceHolder defined in the base page.
Karl 1 1791
Karl, I am trying to Open my Mind.
Should MyBase.CreateChildControls() be first in line??
just guessing.
"Karl Seguin" <karl @ openmymind.net> wrote in message
news:u1*************@TK2MSFTNGP09.phx.gbl... i have a dynamically created user control which contains a non-dynamically created ASP.Net button. When the button is clicked, the event is not
fired. I know that the control must be created on postback, and it is. However, I've noticed an intriguing thing which I think might be at the root of the problem.
My page inherits from a basepage, which in turn inherits from System.Web.UI.Page. On initial load, the events fire something like this:
page.load (aspx page) control.load (dynamically loaded ascx control) base.CreateChildControls (base page) base.Render (base page)
however, on postback, the sequence of events changes to: base.CreateChildControls page.load control.load base.Render
I imagine that this unexpected change of sequence, in addition to what I'm probably doing in CreateChildControls is the cause of my problem. I'm guessing this because if I make my page inherit directly from System.Web.UI.Page, the problem is solved (also, if I don't make the
control dynamic, the problem is solved).
Here's my CreateChildControls in the base page, as I suspect I might be doing something wrong in it:
Protected Overrides Sub CreateChildControls() Me.Controls.Add(_plcContent) Dim mainForm As HtmlForm = CType(Page.FindControl("frmMain"),
HtmlForm) If Not mainForm Is Nothing Then Dim Header As Control = CType(Page.LoadControl("~/Presentation/Header.ascx"), Control) Dim Footer As Control = CType(Page.LoadControl("~/Presentation/Footer.ascx"), Control) mainForm.Controls.AddAt(0, Header) mainForm.Controls.Add(Footer) _plcContent.Controls.Add(mainForm) End If MyBase.CreateChildControls() End Sub
_plcContent is a new PlaceHolder defined in the base page.
Karl
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: DesignerX |
last post by:
I have a user control that contains a custom control, both are loaded
dynamically.
The custom control has a simple required field validator and a text box to
validate.
When the submit button...
|
by: Danny Bloodworth |
last post by:
I have a usercontrol (login.ascx) that is very simple. It accepts
input through two textboxes, and then the user clicks an Imagebutton
to submit.
I have a parent form that checks the page...
|
by: sleigh |
last post by:
Hello,
I'm building a web application that will build a dynamic form based
upon questions in a database. This form will have several different
sections that consist of a panel containing one to...
|
by: Gopal Krish |
last post by:
I'm have coded a simple menu (using link buttons as menu items) in a
user control to be reused across many ASPX pages.
In the page_load method I dynamically create the link buttons as
follows
...
|
by: Wardeaux |
last post by:
All,
looking for sample project on how to add/edit/delete controls from an aspx
page at runtime... any pointers is most appreciated!!
My controls are simple: Label, Textbox, and DropList... I only...
|
by: nicholas |
last post by:
Hello,
Got a kind of e-commerce site.
There are products with product options, such as color, size, etc
All are defined a table:
tbl_products: the table with the products.
tbl_options: the...
|
by: Jeffrey Todd |
last post by:
I have successfully created functionality that mostly models what I'm trying
to do - which is dynamically insert controls into a user control (ascx), and
insert validation controls, also...
|
by: paula |
last post by:
I've got a problem with asp.net i am trying to make a menu control. and have
searched the web for serveral controls but they don't work correctly.
I am pretty new to asp.net building. What am i...
|
by: Nick |
last post by:
I have two navigation user controls and based on a query string will load one
or the other.
On the page that will load the user control I cannot do the following
Dim uc As FlashNavigation (The...
|
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: 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: 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: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
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...
| |