//------------------------------------------------------------------------------
// <copyright company="Telligent Systems">
//     Copyright (c) Telligent Systems Corporation.  All rights reserved.
// </copyright> 
//------------------------------------------------------------------------------

using System.ComponentModel;
using System.Web.UI;
using CommunityServer.Components;

namespace CommunityServer.Controls
{
    [
        ParseChildren( true ),
            PersistChildren( false ),
        ]
    public class QueryStringExists : Control
    {
        private string _qs;
        public string QueryString
        {
            get{return _qs;}
            set{_qs = value;}
        }

        [
            Browsable( false ),
                DefaultValue( null ),
                Description( "TODO SkinTemplate Description" ),
                PersistenceMode( PersistenceMode.InnerProperty ),
            ]
        public ITemplate Template 
        {
            get {return _template;}
            set {_template = value;}
        }
        private ITemplate _template;

        protected override void CreateChildControls() 
        {
            this.Controls.Clear();
            
            if(!Globals.IsNullorEmpty(this.QueryString) && Context.Request.QueryString[this.QueryString] != null && Template != null)
            {
                Control cntrl = new Control();
                Template.InstantiateIn(cntrl);
                this.Controls.Add(cntrl);
            }

        }



    }
}