473,666 Members | 2,634 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CreateChildCont rols and submit from usercontrol

xke
I have a base class which overrides CreateChildCont rols / Render.
Inside CreateChildCont rols, based on a public property ShowLinks in
this class, I can include/display a usercontrol (kind of set of links
like a menu)

A form P inherits this base class. I set the property me.ShowLinks =
true on the load event of P.
P contains another usercontrol (C) which has a button on it.

When I first call P, everything renders fine. First it goes on P_Load,
C_Load, BaseClass:Creat eChildControls and Render. Depends on ShowLinks
property, the links are properly displayed on the page.

The problem is when I press the button from the C control, it changes
the order, it first go to CreateChildCont rols, it doesn't have
ShowLinks set at this moment, it goes afterwards to Load and the Links
do not display properly.

How can I fix this issue?

Thanks

Mar 2 '07 #1
1 3682
xke
Please ignore my previous chaotic post. Thanks for those who wanted to
help me and please let me know if you you see any problems in the
solution I found.

---------- old one ----------------------
Public Class BasePage
Inherits System.Web.UI.P age

Protected Overrides Sub CreateChildCont rols()
Try
'creating my page frame
............... ...........
If IncludeTab Then
'add the toolbar tab menu
Dim ctlMenu As Control =
Me.LoadControl( "UserContro l/tabMenu.ascx")
ctlMenu.ID = "mTabMenuID "
Me.CenterColumn .Controls.Add(c tlMenu)
End If
'keep creating
............... ...........
' Continue base implementation.
MyBase.CreateCh ildControls()
Catch ex As Exception

End Try
End Sub

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
.........
End Sub

---------- solution/workaround ----------------------
Public Class BasePage
Inherits System.Web.UI.P age

Protected Overrides Sub CreateChildCont rols()
Try
'creating my page frame
............... ...........
'keep creating
............... ...........
' Continue base implementation.
MyBase.CreateCh ildControls()
Catch ex As Exception

End Try
End Sub

Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
............. code ..........
If IncludeTab Then
'add the toolbar tab menu
Dim ctl As Control = Me.LoadControl( "UserContro l/
tabMenu.ascx")
ctl.ID = "mTabMenuID "
Me.CenterColumn .Controls.AddAt (0, ctl)
End If
............. code ..........
End Sub

IncludeTab is a Property

--------------------------------------------------------------

Now I am thinking better not posting, it's not a big deal, I've just
moved the dynamic control inclusion from CreateChildCont rols into
Render.

What was the problem: CreateChildCont rols fires after Page_Load ( page
load event) except some cases (a usercontrol in a page contains a
button, click on the button and the order is changed!!!). So, in this
case CreateChildrenC ontrols fires first, and of course Page_Load can't
set some properties inside the BaseClass.

I've spent a day learning the way Microsoft implemented this model and
that there's reasons behind. It didn't help me of course cause it
didnt give me a solution but only reasons why things work the way they
work.

I came with this solution which I hope it's a good one .... pls let me
know if you see anything wrong here.
Thanks,
xke


On Mar 2, 2:43 pm, "xke" <xke...@gmail.c omwrote:
I have a base class which overrides CreateChildCont rols / Render.
Inside CreateChildCont rols, based on a public property ShowLinks in
this class, I can include/display a usercontrol (kind of set of links
like a menu)

A form P inherits this base class. I set the property me.ShowLinks =
true on the load event of P.
P contains another usercontrol (C) which has a button on it.

When I first call P, everything renders fine. First it goes on P_Load,
C_Load, BaseClass:Creat eChildControls and Render. Depends on ShowLinks
property, the links are properly displayed on the page.

The problem is when I press the button from the C control, it changes
the order, it first go to CreateChildCont rols, it doesn't have
ShowLinks set at this moment, it goes afterwards to Load and the Links
do not display properly.

How can I fix this issue?

Thanks

Mar 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2556
by: Alex | last post by:
I believe that when you instantiate a Control derived custom control that implements the virtual method CreateChildControls(), that that base class constructor in Control calls EnsureChildControls() which will invoke CreateChildControls(). Am I correct?
3
7716
by: Arulraja | last post by:
Hello, I have created 2 custom server controls, The parent custom control contains multiple child custom controls. The Child control has a button on it. If I Click the button control, it calls the Parent controls CreateChildControls() method before calling the child control's button click event. Because of this behaviour, I am not getting the changes I made in the
2
1710
by: Jason . | last post by:
I have a user control on page1.aspx that contains 4 listboxes. When I click the submit button, I am doing a Server.Transfer to page2.aspx. On page2.aspx I have the same usercontrol. On page2.aspx when I submit the form it submits it back to the same page. My problem is that the control names on my usercontrol change when I use the server.transfer - i.e. usercontrol:lstCountry changes to usercontrol:lstCountry1. The only way to get the...
0
1507
by: Ferret | last post by:
I've found what seems to be a nasty bug in the DataGrid and Repeater classes. If CreateChildControls gets called before LoadViewState, ViewState fails to map and you end up with nothing on a Postback. Please try the following test, and let me know if you can reproduce this: - Create a custom DataGrid or Repeater class that does nothing but derive from one of the above and gives a place to put breakpoints in overriden handlers - Create...
2
2055
by: Frank | last post by:
Hi! I have a really 'simple' problem. I have an .aspx page with 2 textboxes (login & password) and a Submit button. This works very well, i fill in my login and password and simply press the enter key and the form submits and the Button_Click event on the .aspx page is triggered. Now i also have a usercontrol (.ascx) wich include 1 texbox and also an submit button. Now comes the problem. The page displays correct,
1
2396
by: B Ekre | last post by:
In VS 2005 I have a WebForm with 3 UserControls on it. One UserControl implements the new ICallbackEventHandler to update a DIV based on user input. The other two implement a <asp:repeater ...> bound to a PagedDataSource. The repeaters have associated <asp:linkbutton ...> to page forward and back in the OnClick event. Clicking either link at run-time causes the following error "Microsoft JScript runtime error: Object doesn't support this...
3
1648
by: Iain | last post by:
In my custom control I have overriden CreateChildControls and the first few lines look like this. protected override void CreateChildControls() { Debug.WriteLine("CreateChildControls", "FeatureList"); Controls.Clear(); .. }
1
7044
by: Michael | last post by:
Hi, I'm coding a custom server control, and CreateChildControls() is giving me some pain. I'm just wondering why we have CreateChildControls(), and why this methods seems to be called at different times in the page lifecycle. I mean the order it is called is not deterministic. Example if not post back, then my CreateChildControls() is being executed before my Load event. But for post back, my Load event executes before my...
0
2776
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2) Also within that set of pages, I have a second, distinct seach box and button that searches a specific database that is within an asp:content area
0
8440
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8352
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8549
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7378
agi2029
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4358
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2005
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1763
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.