PopupControlExtender dans un webcontrol

hplusman Messages postés 1 Date d'inscription mercredi 13 avril 2005 Statut Membre Dernière intervention 27 septembre 2007 - 27 sept. 2007 à 14:56
cs_Yxion Messages postés 219 Date d'inscription jeudi 6 juillet 2006 Statut Membre Dernière intervention 7 septembre 2009 - 28 sept. 2007 à 14:14
Bonjour,

Je voudrais pouvoir ajouter dynamiquement un popupControlExtender à partir d'un webcontrol.
Dans la page le PopupControl est lié au webcotnrol au lieu du textbox et je ne comprend pas pourquoi. J'ai essayer de mettre le code à plusieurs endroit (constructeur, init,etc...) mais sans succès.

Merci de votre aide.


Voici le code que j'ai fait et qui ne marche :




using System;
using System.Collections.Generic;
using System.Text;
using AjaxControlToolkit;
using System.Web.UI.WebControls;

    public class DropDownCheckList : CheckBoxList
    {
        TextBox txtChkBox;
        Panel pnlDropDown;
        AjaxControlToolkit.PopupControlExtender popupExtender;

        protected override void CreateChildControls()
        {

            txtChkBox = new TextBox();

            txtChkBox.ID = "txt" + this.ID;

            this.Controls.Add(txtChkBox);


            pnlDropDown = new Panel();

            pnlDropDown.ID = "pnl_" + this.ID;
            pnlDropDown.Height = this.Height;

            pnlDropDown.ScrollBars = ScrollBars.Auto;

            this.Controls.Add(pnlDropDown);


            popupExtender = new AjaxControlToolkit.PopupControlExtender();

            popupExtender.ID = "pExt_" + this.ID;

            popupExtender.Animations = null;


            popupExtender.Position = PopupControlPopupPosition.Bottom;

            popupExtender.TargetControlID = txtChkBox.ID;

            popupExtender.PopupControlID = pnlDropDown.ID;

            this.Controls.Add(popupExtender);



            base.CreateChildControls();

        }

        protected override void Render(System.Web.UI.HtmlTextWriter writer)
        {
            txtChkBox.RenderControl(writer);
            pnlDropDown.RenderBeginTag(writer);
            base.Render(writer);
            pnlDropDown.RenderEndTag(writer);
            popupExtender.RenderControl(writer);
        }
    }
}

1 réponse

cs_Yxion Messages postés 219 Date d'inscription jeudi 6 juillet 2006 Statut Membre Dernière intervention 7 septembre 2009
28 sept. 2007 à 14:14
Essais ca :
           txtChkBox = new TextBox();
            txtChkBox.ID = "txt" + this.ID;
            this.Controls.Add(txtChkBox);

            pnlDropDown = new Panel();
            pnlDropDown.ID = "pnl_" + this.ID;
            pnlDropDown.Height = this.Height;
            pnlDropDown.ScrollBars = ScrollBars.Auto;
            this.Controls.Add(pnlDropDown);

            popupExtender = new AjaxControlToolkit.PopupControlExtender();
            //Je ne connais pas ce control, mais p-e qu'il prend automatiquement son parent
           
this.Controls.Add(popupExtender);   
            popupExtender.ID = "pExt_" + this.ID;
            popupExtender.Animations = null;

            popupExtender.Position = PopupControlPopupPosition.Bottom;
            //Sinon, ca peut venir d'un pb avec l'ID
            popupExtender.TargetControlID = "txt" + this.ID;
            popupExtender.PopupControlID =
"pnl_" + this.ID;

<hr />I love .net
0
Rejoignez-nous