473,804 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Nested PlaceHolders

Hi,

Is there a trick to using nested PlaceHolders?

I have a WebForm that has 3 PlaceHolders on it:

headerPlaceHold er
contentPlaceHol der
footerPlaceHold er

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

leftContentPlac eHolder
centerContentPl aceHolder
rightContentPla ceHolder

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

I'm getting a null reference on the leftContentPlac eHolder.

Any insight into this issue will be greatly appreciated!

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

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

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

"DotNetGruv en" <ms********@jav agruven.com> wrote in message
news:u2******** ******@tk2msftn gp13.phx.gbl...
Hi,

Is there a trick to using nested PlaceHolders?

I have a WebForm that has 3 PlaceHolders on it:

headerPlaceHold er
contentPlaceHol der
footerPlaceHold er

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

leftContentPlac eHolder
centerContentPl aceHolder
rightContentPla ceHolder

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

I'm getting a null reference on the leftContentPlac eHolder.

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(asc x) 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
WebServerContro l 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=tr ue

#Composite Control vs. User Control
http://msdn.microsoft.com/library/de...us/cpguide/htm
l/cpconcompositec ontrolvsusercon trol.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
16926
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. This works fine if all of the properties are at the top (root level) of the model but I'd like to keep them in nested classes to organize them better. So, for example, part of my data model looks like this (simplified) : public class MainClass
5
1289
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 that appear statically, but the run time created controls overwrite them, so is there a way to force the dynamic controls to appear below them, or anywhere I choose really? Also my PlaceHolders have ids of "actname1", "actname2", "actname3" etc,...
4
1382
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 and would appreciate some comments. I intend to write a control that handles the actual display. This control would have a method that gets passed the product ID and the display style ID. It would pull the product details from a database and...
2
1909
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 building. The SQL's all done with placeholders, for safety and ease of twiddling, but EXPLAIN... EXPLAIN doesn't like them. Trying throws an "ERROR: there is no parameter $1" which is somewhat sub-optimal. Any way, short of hand-replacing the...
11
2438
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 statements are fired off (through the C PQexecParams function, if that matters) for execution. No prepares or anything, just bare statements with $1 and friends, with the values passed in as parameters. Straightforward, and no big deal. ...
2
2469
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 and want to be able to populate the ContentPlaceholders of the inner-most masterpage at run-time.
0
958
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 master form, newly added placeholders are shown as "master content placeholders" and i am not able to edit them. regards, saurabh
4
1481
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 banner part being the top level master page and the left content be nested master page named subMaster.master. In this I have 3 div's that I've named
1
1547
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 = new Ajax.Updater( {success: 'placeholder'},
0
9715
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
9595
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,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10352
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10354
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
10097
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9175
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
5535
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
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.