473,472 Members | 1,761 Online
Bytes | Software Development & Data Engineering Community
Create 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="SubForm.ascx.cs"
Inherits="SubForm" %>
<asp:PlaceHolder runat="server" ID="pl" />
SubForm.ascx.cs----------------------
public partial class SubForm : MyBaseUserControl {

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

private ITemplate content = null;

[TemplateContainer(typeof(Content)),
TemplateInstance(TemplateInstance.Single)]
public ITemplate Content {
get { return this.content; }
set { this.content = value; }
}
}

public class Content : Control, INamingContainer{}

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

to your ITemplate property and the

[ParseChildren(true)]
[PersisteChildresn(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="SubForm.ascx.cs"
Inherits="SubForm" %>
<asp:PlaceHolder runat="server" ID="pl" />
SubForm.ascx.cs----------------------
public partial class SubForm : MyBaseUserControl {
protected void Page_Init() {
if (content != null) {
Content container = new Content();
Content.InstantiateIn(container);
pl.Controls.Add(container);
}
}
private ITemplate content = null;

[TemplateContainer(typeof(Content)),
TemplateInstance(TemplateInstance.Single)]
public ITemplate Content {
get { return this.content; }
set { this.content = value; }
}
}
public class Content : Control, INamingContainer{}

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
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...
5
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...
0
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: ...
1
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...
1
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...
6
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...
0
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....
0
by: JohnyStyles | last post by:
I have a templated user control which looks like this: ----------------------------------------------------------------- <uc:MyUserControl runat=server> <TemplateProperty> </TemplateProperty>...
2
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...
0
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,...
0
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...
0
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...
1
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...
0
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,...
1
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...

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.