473,698 Members | 2,643 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET Templated User Controls - Limit child controls allowable within a templated control

I have a templated user control which looks like this:

-----------------------------------------------------------------
<uc:MyUserContr ol runat=server>
<TemplateProper ty>

</TemplatePropert y>
</uc:MyUserContro l>
-----------------------------------------------------------------

Currently i can drop any html/web controls/user controls into
TemplatePropert y. I then handle these inside of my user control, in
the PreRender, I do run:
_templateProper ty.InstantiateI n(aPlaceHolderI nsideUserContro l);

This all works. Very nice, allows for great content encapsulation.

Now, what I would like to do next is limit what controls are allowable
INSIDE of the TemplatePropert y. An example would be only allowing
'asp:Label' to be used, or as in my case, another usercontrol which
I've created.

So idealy, once one types:
-----------------------------------------------------------------
<Template Property>
<[ctrl-space]
-----------------------------------------------------------------

intelisense only allows you to populate the Template Property with
controls that are allowable, i.e. asp:Label, or a another specified
user control, or something of that nature.

ASP.NET actually already does this with some webcontrols. for an
example, look at:
-----------------------------------------------------------------
<asp:DataGrid runat=server>
<Columns>
</Columns>
</asp:DataGrid>
-----------------------------------------------------------------

inside of the Templated Property, Columns, one can only choose from:
<asp:BoundColum n />
<asp:ButtonColu mn />
<asp:EditComman dColumn />
<asp:HyperLinkC olumn />
<asp:TemplateCo lumn />

Any other control inserted in <Columns> will cause compile errors:
Error 4 Validation (ASP.Net): Text is not allowed between the opening
and closing tags for element Columns'.

I'd like to have this same functionality with my controls. Any help
would be greatly appreciated!

Thanx Much,
John Pequeno
.... just another Computer Engineer

May 29 '06 #1
0 2125

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

Similar topics

0
1119
by: Jeff Dockman | last post by:
Background: We needed the ability to create a templated web site that may change in layout from installation to installation. To accomplish this, we created a base Page class that all pages in the site inherit from. In addition to providing basic functionality and security, this Page class modifies the HtmlForm controls collection in the deriving page to manage the page layout. The Page class adds LiteralControls to manipulate the page...
3
1294
by: Brent Minder | last post by:
What is the most efficient way to code asp.net pages when you break your page up into user controls? For example: If you have a page with a header (control .ascx), body, and footer (control .ascx) for a given page and you need to access functions within a class (bizUtil say) should you declare the bizUtil object on the header and footer in both the aspx and aspx.vb pages? That's FOUR references! This seems bloatful (my new word).
0
357
by: John Crowley | last post by:
I keep running into this over and over again... I want a block server control that renders a header and footer, and child controls in between. But I don't want a templated control, for the following reasons: 1) Render blocks are not allowed inside a templated control. 2) I want the inner controls scoped at the parent aspx (or ascx), not at the template naming container. This type of control would be ideal for website headers and...
2
1448
by: Earl Teigrob | last post by:
I have created a simple custom control that uses a table to create space around its contents. The code in the aspx page is show below. My problem is that the controls within the template can not be directly accessed from the code behind. In the code listing below, trying to use "Literal1" control in the code behind results in a null reference exception. How do I make the controls within my templated custom control accessible in the code...
1
1772
by: Hasani \(remove nospam\) | last post by:
The way the system works is, you create a user control (ascx) that will be a template and must implement the interface IPageTemplate. You then create one or more user controls (ascx) that implement the IPageContent interface. A page (aspx) must then be created that loads (using Page.LoadControl) the page template, and the page content. The page content adds itself to the page template. The page template is then added to the aspx's control...
6
1958
by: Louise | last post by:
I use Visual Basic .NET Framework 1.1, Visual Studio. I have a Web page (aspx) referencing a control (ascx) that has a placeholder that is assigned one of 2 child controls through buttons. The ViewState of the second child control gets confused with the first child control - the first Text property in the 2nd child gets updated with the first Text property of the 1st child when the 2nd button is clicked after the 1st. For instance,...
1
3234
by: Andrew Clancy | last post by:
Hi, Myself and a colleague are attempting to mimic the custom template functionality of the ASP.Net 2 Login control. Essentially, we would like to have the ability within our CompositeControl/CompositeControlDesigner to have and Action or Verb in the control's smart tag titled 'Convert to Template' which actually converts the whole control, including it's child controls to templated mode. Do this in the Login control, and you'll see...
15
1877
by: Ofer Zelig | last post by:
I'll describe the simplest situation of the problem. I have a simple Web User Control which only contains a: <div id="bla" runat="server" /. I dynamically add it to a page, by performing: SomeCtl ctl = new SomeCtl(); this.Controls.Add(ctl); and of course apply a <% @ Register %tag in order to make SomeCtl known to
4
2535
by: Mark Olbert | last post by:
I'm running into a well-described issue in the ASPNET model that I haven't found a good work around for. I have a GridView to which I dynamically add data-bound TemplateFields at run-time. The specific fields that are added depend on the state of the application. The contents of these fields displays properly after they are first initialized, but not after postback (e.g., just a simple button control that doesn't do anything except...
0
8683
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
8611
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
9031
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
8904
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
7741
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
5867
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
4372
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...
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2007
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.