|
-
Nov 22nd, 2008, 01:52 PM
#1
Thread Starter
Not NoteMe
[RESOLVED] [2005] ITemplates automatically instanciated at runtime??
I have a class inheriting from a (web) control.
It has 2 templates as below:
Code:
private ITemplate _DisplayTemplate = null;
private ITemplate _LoadingTemplate = null;
[TemplateContainer(typeof(DisplayContainer))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DefaultValue(null)]
public ITemplate DisplayTemplate
{
get { return _DisplayTemplate; }
set { _DisplayTemplate = value; }
}
[TemplateContainer(typeof(DisplayContainer))]
[PersistenceMode(PersistenceMode.InnerProperty)]
[DefaultValue(null)]
public ITemplate LoadingTemplate
{
get { return _LoadingTemplate; }
set { _LoadingTemplate = value; }
}
For reference here's the DisplayContainer and LoadingContainer, just empty classes:
Code:
public class DisplayContainer : Control, INamingContainer
{
}
public class LoadingContainer : Control, INamingContainer
{
}
Nowhere in the code do i instanciate these classes.
Dispite this, at runtime when i navigate to the page containing this control both templates display on the page (once set of controls for each template).
All examples i've seen have some sort of container control, then instanciate the templates in a runtime-created control and add them to that container control, but i've not even done that since i want to show different templates depending on different conditions.
Surely with no code to instanciate any templates there should be no markup shown for my new control (beyond maybe an empty div or something).
What am i missing?
Last edited by SLH; Nov 24th, 2008 at 04:20 PM.
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 24th, 2008, 12:34 PM
#2
Re: [2005] ITemplates automatically instanciated at runtime??
How are they placed on the page?
-
Nov 24th, 2008, 12:52 PM
#3
Thread Starter
Not NoteMe
Re: [2005] ITemplates automatically instanciated at runtime??
Cheers for the reply.
 Originally Posted by mendhak
How are they placed on the page?
Code:
<hwc:DeferredLoading ID="DeferredLoading1" runat="server">
<DisplayTemplate>
<asp:SqlDataSource runat="server" ID="dsSQLDataSource1" SelectCommand="S...." ConnectionString="<%$ ..... %>"></asp:SqlDataSource>
<asp:GridView runat="server" ID="GridView1" DataSourceID="dsSQLDataSource1">
</asp:GridView>
</DisplayTemplate>
<LoadingTemplate>
Loading!
</LoadingTemplate>
</hwc:DeferredLoading>
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 24th, 2008, 02:22 PM
#4
Re: [2005] ITemplates automatically instanciated at runtime??
I haven't ventured much into this territory but from what I do know, I think you'll need to set the visibilities of those templates rather than Instantiate them. The TemplateContainer attribute is supposed to be the naming container rather than the 'HTML' container of your template, so it shouldn't make a difference if it's there or not. I might be wrong though but I'm half right half the time. Except when I'm not right.
-
Nov 24th, 2008, 03:40 PM
#5
Thread Starter
Not NoteMe
Re: [2005] ITemplates automatically instanciated at runtime??
Cheers Mendhak! That did it. I didn't realise i had to instanciate both templates in the overloaded CreateChildControls method. Once i'd done that and made the container controls private members i could change their visibility accordingly.
Looks like you weren't not right this time.
Now, to make a designer for my new-fangled control!
Quotes:
"I am getting better then you guys.." NoteMe, on his leet english skills.
"And I am going to meat her again later on tonight." NoteMe
"I think you should change your name to QuoteMe" Shaggy Hiker, regarding NoteMe
"my sweet lord jesus. I've decided never to have breast implants" Tom Gibbons
Have I helped you? Please Rate my posts. 
-
Nov 26th, 2008, 04:53 AM
#6
Re: [RESOLVED] [2005] ITemplates automatically instanciated at runtime??
My only reaction is no wai wow.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|