Link to home
Start Free TrialLog in
Avatar of davyquyo
davyquyo

asked on

adding custom control in updatepanel dynamicly

Hey everyone

I try to make a control but I'm still expirementing and encountered a problem.
I experiment with making a custom ajax wizard so I made the base of that ajax wizard to see its result but somehow what I did is not rendering.

Problem with the code I writed is.
when I look at the html I can see the updatepanel div is there but nothing is inside. Everything I wirte in my AjaxWizardStep is not rendered in the updatepanel. How can I solve this problem becuase without updatepanel it works perfect.

The HTML I tried is here but somehow the text "This is a Test" is not rendered.

<ajax:AjaxWizard runat="server" ID="test">
            <WizardSteps>
                <ajax:AjaxWizardStep runat="server" ID="aws1">
                    This is a Test
                </ajax:AjaxWizardStep>
            </WizardSteps>
        </ajax:AjaxWizard>
namespace ajax.Web.UI.WebControls
{
    [ParseChildren(true)]
    public class AjaxWizard : Control
    {
        AjaxWizardStepCollection steps;

        [PersistenceModeAttribute(PersistenceMode.InnerProperty)]
        public virtual AjaxWizardStepCollection WizardSteps
        {
            get {
                if (steps == null)
                    steps = new AjaxWizardStepCollection();
                return steps;
            }
        }

        protected override void Render(HtmlTextWriter writer)
        {
            UpdatePanel up = new UpdatePanel();
            up.ID = this.ID;
            foreach (AjaxWizardStep step in steps)
            {
                up.ContentTemplateContainer.Controls.Add(step);
            }
            Controls.Add(up);
            up.RenderControl(writer);
            //base.Render(writer);
        }
    }

    public sealed class AjaxWizardStep : AjaxWizardStepBase
    {

    }

    public abstract class AjaxWizardStepBase : View
    {

    }

    public sealed class AjaxWizardStepCollection : IList
    {
        private ArrayList list = new ArrayList();

        internal AjaxWizardStepCollection() { }

        public IEnumerator GetEnumerator()
        {
            return list.GetEnumerator();
        }

        public object SyncRoot
        {
            get { return this; }
        }

        public bool IsSynchronized
        {
            get { return false; }
        }

        public int Count
        {
            get { return list.Count; }
        }

        public void CopyTo(AjaxWizardStepBase[] array, int index)
        {
            list.CopyTo(array, index);
        }

        void ICollection.CopyTo(Array array, int index)
        {
            list.CopyTo(array, index);
        }

        bool IList.IsFixedSize
        {
            get { return false; }
        }

        public bool IsReadOnly
        {
            get { return false; }
        }

        public AjaxWizardStepBase this[int index]
        {
            get { return (AjaxWizardStepBase)list[index]; }
        }

        object IList.this[int index]
        {
            get { return list[index]; }
            set { list[index] = value; }
        }

        public void RemoveAt(int index)
        {
            list.RemoveAt(index);
        }

        public void Remove(AjaxWizardStepBase ajaxWizardStep)
        {
            if (ajaxWizardStep == null)
                throw new ArgumentNullException("ajaxWizardStep");
            list.Remove(ajaxWizardStep);
        }

        void IList.Remove(object ob)
        {
            Remove((AjaxWizardStepBase)ob);
        }

        public void Insert(int index, AjaxWizardStepBase ajaxWizardStep)
        {
            list.Insert(index, ajaxWizardStep);
        }

        void IList.Insert(int index, object ob)
        {
            Insert(index, (AjaxWizardStepBase)ob);
        }

        public int IndexOf(AjaxWizardStepBase ajaxWizardStep)
        {
            if (ajaxWizardStep == null)
                throw new ArgumentNullException("ajaxWizardStep");
            return list.IndexOf(ajaxWizardStep);
        }

        int IList.IndexOf(object ob)
        {
            return IndexOf((AjaxWizardStepBase)ob);
        }

        public void Clear()
        {
            list.Clear();
        }

        public bool Contains(AjaxWizardStepBase ajaxWizardStep)
        {
            if (ajaxWizardStep == null)
                throw new ArgumentNullException("ajaxWizardStep");
            return list.Contains(ajaxWizardStep);
        }

        bool IList.Contains(object ob)
        {
            return Contains((AjaxWizardStepBase)ob);
        }

        public void Add(AjaxWizardStepBase ajaxWizardStep)
        {
            if (ajaxWizardStep == null)
                throw new ArgumentNullException("ajaxWizardStep");
            list.Add(ajaxWizardStep);
        }

        int IList.Add(object ob)
        {
            return list.Add((AjaxWizardStepBase)ob);
        }
    }
}

Open in new window

Avatar of Amandeep Singh Bhullar
Amandeep Singh Bhullar
Flag of India image

Avatar of davyquyo
davyquyo

ASKER

I really thank you for the fast respons but I can't figure out what my problem is here.
I'm able to add custom controls to my page. thats not the problem.
My problem is to dynamicly add custom controls to an updatepanel.
If I add for example a normal textbox to an updatepanel it works perfect but when I add that wizardstep to the updatepanel it doesn't render a thing. I already checked if the wizardstep is found and yes it is found.

I really hope someone can help me out here.
ASKER CERTIFIED SOLUTION
Avatar of davyquyo
davyquyo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial