Vous êtes ici Forums
  |  Connexion
 Forums
HomeHomeForums DNNForums DNNDéveloppementDéveloppement[DNN4] Création dynamique d[DNN4] Création dynamique d'un SectionHead
Précédente
 
Suivante
Nouveau message
08/07/2009 10:18
 

Bonjour à tous,

J'aimerais mettre dynamiquement un SectionHead dans une cellule de tableau de cette manière:

            TableRow ligne = new TableRow();
            TableCell Cellule = new TableCell();
            Cellule.CssClass = "SubHead";

            idGen += 1;
            string LibIdGen = idGen.ToString();
            Table tbl = new Table();
            tbl.ID = "tbl" + LibIdGen;

            SectionHeadControl sh = new SectionHeadControl();
            sh.ID = "sh" + LibIdGen;
            sh.Section = "tbl" + LibIdGen;

            //Cellule.Text = (affNb) ? titre.ToUpper() + " (" + adhs.Count.ToString() + ")" : titre.ToUpper();
            Cellule.Controls.Add(sh);
            ligne.Controls.Add(Cellule);
            Infos.Controls.Add(ligne);

            sh.CssClass = "SubHead";
            sh.IsExpanded = false;
            sh.IncludeRule = true;
            sh.Text = (affNb) ? titre.ToUpper() + " (" + adhs.Count.ToString() + ")" : titre.ToUpper();

Seulement, il me met:

La référence d'objet n'est pas définie à une instance d'un objet. à DotNetNuke.UI.UserControls.SectionHeadControl.set_CssClass(String Value)

Je ne peux définir les propriétés de SH (text, cssClass, IsExpanded, IncludeRule, ...).

Comme si le composant avait été mal déclaré...

Avez vous une idée ?

Merci d'avance.

 
Nouveau message
09/07/2009 21:38
 

Trouvé dans admin/Authentication/Authentication.ascx.vb :

Dim sectionHeadControl As SectionHeadControl = CType(LoadControl("~/controls/SectionHeadControl.ascx"), SectionHeadControl)

Trouvé dans admin/Authentication/Login.ascx.vb :

Dim sectionHeadControl As SectionHeadControl = Nothing
sectionHeadControl = CType(LoadControl("~/controls/SectionHeadControl.ascx"), SectionHeadControl)
sectionHeadControl.IncludeRule = True
sectionHeadControl.CssClass = "Head"
sectionHeadControl.Text = Localization.GetString("Title", authLoginControl.LocalResourceFile)
sectionHeadControl.Section = container.ID
 'Add Section Head Control to Container
pnlLoginContainer.Controls.Add(sectionHeadControl)

Seb

 
Nouveau message
31/07/2009 09:46
 

Bonjour Seb,

Merci pour votre réponse, mais toujours ce pb de notification, grrr... Je viens de changer d'@, pour voir.

Entre temps, j'ai vu que je ne créais pas le controle comme il fallait, j'ai bien fait ça:

                SectionHeadControl mySh = (SectionHeadControl)(LoadControl("~/controls/SectionHeadControl.ascx"));
                mySh.Section = tbl.ID;
                mySh.IsExpanded = false;
                mySh.IncludeRule = true;
                mySh.Text = (affNb) ? titre.ToUpper() + " (" + adhs.Count.ToString() + ")" : titre.ToUpper();
                Cellule.Controls.Add(mySh);

Mais rien à faire, ne fonctionne pas... Il ne doit pas vouloir le créer dans une cellule de tableau.

J'ai donc fait un truc à la main:

            string strTab = "<div id='desc" + LibIdGen.ToString() + "' style='display:none;'>Mon contenu à cacher/afficher</div>";
            LiteralControl tab = new LiteralControl(strTab);
            ...
            LiteralControl img = new LiteralControl(titre.ToUpper() + " (" + adhs.Count.ToString() + ") "
                    + "<a href=' affiche(" + LibIdGen.ToString() + ");'>"
                    + "<img src='" + ResolveUrl("Images/plus.gif") + "' id='img" + LibIdGen.ToString() + "' border=0 /></a>");
             Cellule.Controls.Add(img);

Et avec un javascript qui contient cette fonction:

function affiche(cle) { // Affiche ou cache un contenu
    obj1 = window.document.getElementById('desc'+cle);
    obj2 = window.document.getElementById('img'+cle);
    if(obj1.style.display=='none') {
        obj1.style.display='block';
        obj2.src = obj2.src.replace('plus.gif','minus.gif');
    } else {
        obj1.style.display='none';
        obj2.src = obj2.src.replace('minus.gif','plus.gif');
    }
}

Ca fonctionne bien, mais vraiment, des fois, j'ai vraiement l'impression de faire du PHP avec dot net. :-(

 
Nouveau message
31/07/2009 14:27
 

Tu peux essayer de place un PlaceHolder en runat server dans ton contrôle, puis d'ajouter dynamiquement le sectionHead dedans ?

 
Précédente
 
Suivante
HomeHomeForums DNNForums DNNDéveloppementDéveloppement[DNN4] Création dynamique d[DNN4] Création dynamique d'un SectionHead