adding custom control in updatepanel dynamicly

davyquyo
davyquyo used Ask the Experts™
on
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

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
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.
Commented:
I think I found the problem.

I have added this

public abstract class AjaxWizardStepBase : View
    {

    }

The problem is the the integrated VIew control because when I change "View" to "Control" then it do work fine. I try to work from there now.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial