IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

SharePoint .NET Discussion :

Problème de création d'un custom Field


Sujet :

SharePoint .NET

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2007
    Messages
    236
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Février 2007
    Messages : 236
    Par défaut Problème de création d'un custom Field
    Bonjour, j'ai réalisé un custom Field qui contient une liste déroulante. J'ajoute sans problème le custom Field dans la liste mais quand je crée un nouveau item je ne vois pas le dropdownList dans le champ spécifié :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
     
    <%@Assembly Name="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>
    <%@Register TagPrefix="SharePoint" Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" namespace="Microsoft.SharePoint.WebControls"%>
     
    <SharePoint:RenderingTemplate ID="AnneeCustomFieldControl" runat="server">
     
        <Template>
            <asp:DropDownList runat="server" ID="DropDownListAnnee" />
        </Template>
     
    </SharePoint:RenderingTemplate>
     
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using Microsoft.SharePoint;
    using Microsoft.SharePoint.WebControls;
     
    namespace AnneeCustomField
    {
        public class AnneeCustomField : SPFieldChoice
        { 
     
     
     
            public AnneeCustomField(SPFieldCollection fields, string fieldName)
                : base(fields, fieldName)
            {
                //this.Choices.Add("2007");
                //this.Choices.Add("2008");
                //this.Choices.Add("2009");
                //this.DefaultValue = "2007";
            }
            public AnneeCustomField(SPFieldCollection fields, string typeName, string displayName)
                : base(fields, typeName, displayName)
            {
                //this.Choices.Add("2007");
                //this.Choices.Add("2008");
                //this.Choices.Add("2009");
                //this.DefaultValue = "2007";
            }
     
            public override BaseFieldControl FieldRenderingControl
            {
                get
                {
                    AnneeCustomFieldControl AnneeCustomFieldControl = new AnneeCustomFieldControl();
     
                    AnneeCustomFieldControl.FieldName = InternalName;
     
                    return AnneeCustomFieldControl;
                }
            }
        }
     
    }
     
     
    using System;
    using System.Collections.Generic;
    using System.Text;
    using System.Web;
    using System.Web.Configuration;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using Microsoft.SharePoint.WebControls;
     
    namespace AnneeCustomField
    {
        class AnneeCustomFieldControl : BaseFieldControl
        {
            public class ActiveDirectoryUserQueryFieldControl : BaseFieldControl
            {
                protected DropDownList DropDownListAnnee;
     
                protected override string DefaultTemplateName
                {
                    get
                    {
                        //Return the name of the ascx 
                        return "AnneeCustomFieldControl";
                    }
                }
     
                public override object Value
                {
                    get
                    {
                        EnsureChildControls();
                        return DropDownListAnnee.SelectedValue.ToString();
                    }
     
                    set
                    {
                        EnsureChildControls();
                        DropDownListAnnee.SelectedValue = (string)this.ItemFieldValue;
                    }
                }
     
                //Make sure that the combo box gets focus whenever the field does.
                public override void Focus()
                {
                    EnsureChildControls();
                    DropDownListAnnee.Focus();
                }
     
                protected override void CreateChildControls()
                {
     
                    if (Field == null) return;
     
                    base.CreateChildControls();
     
     
                    if (ControlMode == Microsoft.SharePoint.WebControls.SPControlMode.Display)
                        return;
     
                    //Get the combo box from the template.
                    DropDownListAnnee = (DropDownList)TemplateContainer.FindControl("DropDownListAnnee");
     
                    if (DropDownListAnnee == null)
                    {
                        throw new ArgumentException("cboUsers is null. Corrupted ActiveDirectoryUserQueryFieldControl.ascx file.");
                    }
     
                    if (!Page.IsPostBack)
                    {
                        try
                        {
                            //Populate the combo box with user names.
                            DropDownListAnnee.Items.Add("2005");
                            DropDownListAnnee.Items.Add("2006");
                            DropDownListAnnee.Items.Add("2007");
                        }
                        catch (Exception ex)
                        {
     
                        }
                    }
                }
            }
     
     
        }
    }

    J'ai essayé de voir tout sur le net j'ai appliqué les mêmes trucs mais bizarre !
    J'espère que vous puissiez m'aider

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Avril 2008
    Messages
    1 519
    Détails du profil
    Informations personnelles :
    Âge : 41
    Localisation : France

    Informations forums :
    Inscription : Avril 2008
    Messages : 1 519
    Par défaut
    J'aurais tendance à dire qu'il te manque un this.Controls.Add(DropDownListAnnee) dans ton CreateChildControls.

Discussions similaires

  1. [SP-2007] Création d'un custom field
    Par Magohamoths dans le forum SharePoint
    Réponses: 2
    Dernier message: 04/05/2009, 10h33
  2. Création Custom fields
    Par glucas59 dans le forum SharePoint
    Réponses: 2
    Dernier message: 02/03/2009, 09h13
  3. Problème Display pattern(custom field) + javascript
    Par lightbulb dans le forum SharePoint
    Réponses: 1
    Dernier message: 17/02/2009, 15h49
  4. Problème de création de fenêtre
    Par tomateauketchup dans le forum DirectX
    Réponses: 1
    Dernier message: 08/06/2003, 19h42
  5. [Rave Report] problème de création dynamique
    Par Nivux dans le forum Rave
    Réponses: 2
    Dernier message: 24/05/2003, 00h07

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo