473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Nested PlaceHolders

Hi,

Is there a trick to using nested PlaceHolders?

I have a WebForm that has 3 PlaceHolders on it:

headerPlaceHolder
contentPlaceHolder
footerPlaceHolder

Everything works well until I add a UserControl to the
contentPlaceHolder which has 3 placeHolders on it:

leftContentPlaceHolder
centerContentPlaceHolder
rightContentPlaceHolder

All controls are added to place holders in the Page_Load event
handler.

I'm getting a null reference on the leftContentPlaceHolder.

Any insight into this issue will be greatly appreciated!

TIA,
geo
Nov 18 '05 #1
3 4835
Additional information!

The problem seems to be with UserControls that I'm using new instead of
Page.LoadControl()!

Some of the user controls that are being used have Properties that cause the
content to be modified. So, I tried using new on them, then with the local
reference, I'd set the properties and then use the local reference to add
the control to the pages controls collection.

So, the question now is:

What is the difference between newing a UserControl and Loading a
UserControl??

TIA
goe

"DotNetGruven" <ms********@javagruven.com> wrote in message
news:u2**************@tk2msftngp13.phx.gbl...
Hi,

Is there a trick to using nested PlaceHolders?

I have a WebForm that has 3 PlaceHolders on it:

headerPlaceHolder
contentPlaceHolder
footerPlaceHolder

Everything works well until I add a UserControl to the
contentPlaceHolder which has 3 placeHolders on it:

leftContentPlaceHolder
centerContentPlaceHolder
rightContentPlaceHolder

All controls are added to place holders in the Page_Load event
handler.

I'm getting a null reference on the leftContentPlaceHolder.

Any insight into this issue will be greatly appreciated!

TIA,
geo

Nov 18 '05 #2
Hi Geo,

Thanks for posting in the community!
From your description, you have a custom ASP.NET UserControl(ascx) and you
used it in a certain web page. You tried both using "new" constrcutor and
the LoadControl( ascx file) to create a new control and found that the
"new" constructor not worked. So you're wondering what''re the differences
bewteen the two means,yes?

As for this question, here are my suggestions on it:
The ASP.NET UserControl is a kind of Template based controls which has its
own template (in the ascx file), something like the include file in the
classic asp. When using it in a certain container page. The ASP.NET runtime
will first compile and generate the UserControl's class instance from the
ascx source template. So generally, there're two means to add a ascx
UserControl into a page:'
1. Statically add it onto page via add UserControl's declaration and tag.

2. Using LoadControl to dynamically load a UserControl instance from an
ascx file.

If you use "new" constructor to create a certain UserControl class
instance, it doesn't load the control's source content from the ascx
template, so it is not actually a complete UserControl instance. I think
you should still use the LoadControl method and then set the certain
properties of the controls before adding it to page.

If you'd like to use "new" constructor to create a certain control instance
like asp.net TextBox or Label, you need to develop a ASP.NET
WebServerControl which is quite different from UserControl.

Here are some tech reference on ASP.NET UserControl and WebSErver Control
in MSDN:

#Web Forms User Controls
http://msdn.microsoft.com/library/en...ormsusercontro
ls.asp?frame=true

#Composite Control vs. User Control
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcompositecontrolvsusercontrol.asp

#ASP.NET Server Control Development Basics
http://msdn.microsoft.com/library/en...ormscontroldev
elopmentbasics.asp?frame=true

Hope these help.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #3
Hi Geo,

Have you had a chance to check out my suggestions or have you got any
further ideas on this issue? If you have any thing unclear, please feel
free to post here.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx

Nov 18 '05 #4

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

Similar topics

8
by: Robert W. | last post by:
I've almost completed building a Model-View-Controller but have run into a snag. When an event is fired on a form control I want to automatically updated the "connnected" property in the Model. ...
5
by: Colin Basterfield | last post by:
Hi, I have some placeholders in my .aspx file, and when I add my controls to them at runtime I want them to appear in specific positions on the web form, however there are already some controls...
4
by: Alan Silver | last post by:
Hello, I am displaying product details on a page and am allowing the site owner to specify the style in which the product details are displayed. I am debating which of two approaches to use here...
2
by: Dan Sugalski | last post by:
Is there any way to convince explain to go do its thing when given a query with placeholders in it? I'm trying to do some performance checking of some of the queries built into a system I'm...
11
by: Dan Sugalski | last post by:
Is there any good way to speed up SQL that uses like and has placeholders? Here's the scoop. I've got a system that uses a lot of pre-generated SQL with placeholders in it. At runtime these SQL...
2
by: iturner100 | last post by:
Hi, I've been struggling with this one for a couple of hours without much joy. Basically, I've got a set of nested masterpages (3 as it happens). I'm dynamically generating a new page in code...
0
by: nemesis.saurabh | last post by:
hi, i am using VS 2005. i have created a master.master. i have added 2 content placeholders, i am able to edit them in the corresponding content page but if i am adding anymore placeholders in...
4
by: D | last post by:
Hi, I've been toying around with master pages and am trying to set up your standard banner across the top and 3 areas below that, left content, center content and right content. I have the...
1
by: pankajit09 | last post by:
Hello, Is it possible to put two placeholders in Ajax Updater ? or Can I use the same placeholder(div ID ) at two places in HTML? var myAjax =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
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...
0
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
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
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.