Need help with a Templated ASP.NET Control

Mike Andrews <[email protected]>
Newsgroups gmane.comp.windows.devel.dotnet.web
Message-ID <[email protected]>
Guys,

I'm at my wits end here on this templated control.  I cannot get it to
function properly.
Perhaps a look by someone else can tell me where I'm going wrong.

The problem is that when I try to use the <%# Container.xxxx %> syntax for
the template in the asp.net markup, the Container field returns my parent
object and not the template object.

Any suggestions?

Thanks,
Mike

Here's the basics of the control:


    [DefaultProperty("UploadURL")]
    [PersistChildren(true)]
    [ToolboxData("<{0}:ScannerControl runat=server></{0}:ScannerControl>")]
    public class ScannerControl : Control, INamingContainer {

        public ScannerControl(): base() { }

        ...

        private ITemplate _toolbarTemplate;
        /// <summary>
        /// Gets or sets the template...
        /// </summary>
        [PersistenceMode(PersistenceMode.InnerProperty)]
        [TemplateContainer(typeof(ToolbarTemplate))]
        public ITemplate ToolbarTemplate {
            get { return _toolbarTemplate; }
            set { _toolbarTemplate = value; }
        }

        protected override void CreateChildControls() {
            Controls.Clear();
            if (ToolbarTemplate != null) {
                ToolbarTemplate tt = new ToolbarTemplate();
                ToolbarTemplate.InstantiateIn(tt);
                Controls.Add(tt);
            }
        }

 }


    /// <summary>
    ///
    /// </summary>
    public class ToolbarTemplate: Control, INamingContainer {

        public ToolbarTemplate() { }

        public ToolbarTemplate(string javascriptCommand, string tooltip) {
            this.JavascriptCommand = javascriptCommand;
            this.ToolTip = tooltip;
        }

        private string _javascriptCommand;
        /// <summary>
        /// Gets or sets ...
        /// </summary>
        public string JavascriptCommand {
            get { return _javascriptCommand; }
            set { _javascriptCommand = value; }
        }

        private string _toolTip;
        /// <summary>
        /// Gets or sets ...
        /// </summary>
        public string ToolTip {
            get { return _toolTip; }
            set { _toolTip = value; }
        }


    }

===================================
This list is hosted by DevelopMentor®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.