Results 1 to 6 of 6

Thread: [RESOLVED] [2005] ITemplates automatically instanciated at runtime??

  1. #1

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    [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.


  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] ITemplates automatically instanciated at runtime??

    How are they placed on the page?

  3. #3

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    Re: [2005] ITemplates automatically instanciated at runtime??

    Cheers for the reply.
    Quote 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.


  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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.

  5. #5

    Thread Starter
    Not NoteMe SLH's Avatar
    Join Date
    Mar 2002
    Location
    192.168.0.1 Preferred Animal: Penguin Reason for errors: Line#38
    Posts
    3,051

    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.


  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    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
  •  



Click Here to Expand Forum to Full Width