473,804 Members | 3,532 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Templated User Control & intellisense

Hi,
I built a very simple templated user control but unfortunately, the template
"Content" is not recognized by intellisense and it says that my component
"SubForm" is not supposed to contain anything.
Any idea ?
Thanks

SubForm.ascx-------------------------
<%@ Control Language="C#" AutoEventWireup ="true" CodeFile="SubFo rm.ascx.cs"
Inherits="SubFo rm" %>
<asp:PlaceHolde r runat="server" ID="pl" />
SubForm.ascx.cs----------------------
public partial class SubForm : MyBaseUserContr ol {

protected void Page_Init() {
if (content != null) {
Content container = new Content();
Content.Instant iateIn(containe r);
pl.Controls.Add (container);
}
}

private ITemplate content = null;

[TemplateContain er(typeof(Conte nt)),
TemplateInstanc e(TemplateInsta nce.Single)]
public ITemplate Content {
get { return this.content; }
set { this.content = value; }
}
}

public class Content : Control, INamingContaine r{}

Using---------------------------------
<puc:SubForm runat="server">
<Content>
<asp:Label runat="server" />
something else
etc.
</Content>
</puc:SubForm>
Dec 12 '05 #1
1 2936
You also need to apply
[PersistenceMode (PersistenceMod e.InnerProperty )]]

to your ITemplate property and the

[ParseChildren(t rue)]
[PersisteChildre sn(false)]

to your control class.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi,
I built a very simple templated user control but unfortunately, the
template
"Content" is not recognized by intellisense and it says that my
component
"SubForm" is not supposed to contain anything.
Any idea ?
Thanks
SubForm.ascx-------------------------
<%@ Control Language="C#" AutoEventWireup ="true"
CodeFile="SubFo rm.ascx.cs"
Inherits="SubFo rm" %>
<asp:PlaceHolde r runat="server" ID="pl" />
SubForm.ascx.cs----------------------
public partial class SubForm : MyBaseUserContr ol {
protected void Page_Init() {
if (content != null) {
Content container = new Content();
Content.Instant iateIn(containe r);
pl.Controls.Add (container);
}
}
private ITemplate content = null;

[TemplateContain er(typeof(Conte nt)),
TemplateInstanc e(TemplateInsta nce.Single)]
public ITemplate Content {
get { return this.content; }
set { this.content = value; }
}
}
public class Content : Control, INamingContaine r{}

Using---------------------------------
<puc:SubForm runat="server">
<Content>
<asp:Label runat="server" />
something else
etc.
</Content>
</puc:SubForm>

Dec 13 '05 #2

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

Similar topics

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...
5
3167
by: Marcel Gelijk | last post by:
Hi, I am trying to create a User Control that is located in a seperate class library. The User Control contains a textbox and a button. The page generates an exception when it tries to access the code variable that are supposed to be linked to the contained controls. It runs fines when everything is contained in a single web form project. What do I need to do to make it work from a class library?
0
1139
by: Ricky Li | last post by:
I went through some article to see how I can add schema validation for my templated control by adding an XSD file into the VS.NET schema folder. Everything works fine for a schema like this: <mycontrolns:mycontrol id="test" runat="server"> <mytemplate>test</mytemplate> </mycontrolns> and I was able to specify the XSD to validate "mytemplate" as the only valid child type for "mycontrol". Here's a challenge: Is there anyway
1
2329
by: Kris van der Mast | last post by:
Hi, been a while since I posted a question myself instead of trying to help others out. I'm refactoring an existing web app that uses dynamic loading of user controls and a lot of response.redirects to the same page. Because I hate the overhead by doing this I'm searching for a cleaner option. But I'm having troubles (off course or I wouldn't be posting this).
1
1779
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
3383
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all the usual stuff of recreating the usercontrol in the Page Init event. The 'failure' sequence is as follows: - select web form button to display the user control - select user control button, event fires - select web form button to display...
0
1089
by: Michael Carr | last post by:
I am trying to add a user control to a web form and implement one of the control's events. However, when I add the user control to the form, intellisense doesn't seem to detect it as a control. Even if it does, it doesn't detect the control's events because when I switch to Designer view to implement the event, there are no events listed for the control in the properties box. With VS 2003 I used to just implement events by manually...
0
2134
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty> </uc:MyUserControl> -----------------------------------------------------------------
2
4325
by: =?Utf-8?B?TWljaGFlbCBkZSBWZXJh?= | last post by:
To all, I'm trying to bind a dataset to a listbox control that is in a gridview's templated field. However, in the code behind the intellisense does not recognize the ID name of my listbox control....thus not giving me an opportunity to bind the listbox's datasource to a dataview. Can you make any recommendations? I'm trying to put a list box within a gridview so that an end user may select a record from the listbox and relate the...
0
9706
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
10580
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...
1
10323
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
10082
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
9157
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...
1
7621
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5652
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3821
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2993
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.