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

ASP.NET Discussion :

Ma page ne rentre pas dans la fonction Page_Load


Sujet :

ASP.NET

  1. #1
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2007
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 375
    Points : 154
    Points
    154
    Par défaut Ma page ne rentre pas dans la fonction Page_Load
    Bonjour,

    J'ai un petit problème.
    J'ai mis ma fonction page_load dans le code behind, mais elle n'est pas appelée au chargement de mon site. Les autres fonctions marchent très bien, donc le code behind est bien reconnu.

    je post mon code behind.
    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
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    using System;
    using System.Data;
    using System.Data.OracleClient;
    using System.Configuration;
    using System.Linq;
    using System.Web;
    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 System.Xml.Linq;
    using Utilities;
     
    public class CodeBehindPosition : System.Web.UI.UserControl
    {
        protected static String sQuery;
     
        protected DropDownList ddlAffair;
        protected DropDownList ddlTower;
        protected DropDownList ddlTeam;
        protected DropDownList ddlPosition;
        protected DropDownList ddlBU;
        protected TextBox tbStartDateTeam;
        protected Calendar CalendarStartTeam;
        protected TextBox tbEndDateTeam;
        protected Calendar CalendarEndTeam;
        protected Label lbAffair;
        protected Label lbTower;
        protected Label lbTeam;
        protected Label lbPosition;
        protected Label lbBU;
     
        protected DropDownList ddl;
     
        protected void Page_Load(object sender, EventArgs e)
        {
            getControls();
     
            if (ddlAffair.Items.Count == 0)
            {
                sQuery = "SELECT IDAFFAIR, DESIGNATIONAFFAIR FROM affair";
                fillDropDownList("", sQuery, "ddlAffair");
                ddlAffair.Items.Add("Select the affair");
                ddlAffair.SelectedValue = "Select the affair";
                displayControls(true, false, false, false, false, false);
            }
        }
     
        public void fillDropDownList(String sConnectionString, String sQuery, String sListName)
        {
            System.Data.OracleClient.OracleConnection conn = Tool.connect(sConnectionString);
            System.Data.OracleClient.OracleDataReader reader = Tool.executeQuery(sQuery, conn);
     
            ddl = (DropDownList)FindControl(sListName);
            ddl.DataSource = reader;
            ddl.DataBind();
     
     
            Tool.deconnect(conn);
     
        }
     
        protected void getControls()
        {
            ddlAffair = (DropDownList)FindControl("ddlAffair");
            ddlTower = (DropDownList)FindControl("ddlTower");
            ddlTeam = (DropDownList)FindControl("ddlTeam");
            ddlPosition = (DropDownList)FindControl("ddlPosition");
            ddlBU = (DropDownList)FindControl("ddlBU");
            tbStartDateTeam = (TextBox)FindControl("tbStartDateTeam");
            CalendarStartTeam = (Calendar)FindControl("CalendarStartTeam");
            tbEndDateTeam = (TextBox)FindControl("tbEndDateTeam");
            CalendarEndTeam = (Calendar)FindControl("CalendarEndTeam");
            lbAffair = (Label)FindControl("lbAffair");
            lbTower = (Label)FindControl("lbTower");
            lbTeam = (Label)FindControl("lbTeam");
            lbPosition = (Label)FindControl("lbPosition");
            lbBU = (Label)FindControl("lbBU");
        }
     
        protected void ddlAffair_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlAffair.SelectedValue != "Select the affair")
            {
                sQuery = "SELECT designationTower, IDTower FROM affair a " +
                    "JOIN poste p on a.idaffair= p.affair_idaffair " +
                    "JOIN team t on p.team_idteam= t.idteam " +
                    "JOIN tower tow on t.tower_IDtower= tow.IDtower where idaffair = '" + ddlAffair.SelectedValue + "'";
                ddlTower.Items.Clear();
                fillDropDownList("", sQuery, "ddlTower");
                ddlTower.Items.Add("Select the tower");
                ddlTower.SelectedValue = "Select the tower";
                displayControls(true, true, false, false, false, false);
            }
            else
            {
                displayControls(true, false, false, false, false, false);
            }
        }
     
        protected void ddlTower_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlTower.SelectedValue != "Select the tower")
            {
                sQuery = "SELECT designationTeam, idTeam FROM affair a " +
                    "JOIN poste p on a.idaffair= p.affair_idaffair " +
                    "JOIN team t on p.team_idteam= t.idteam " +
                    "JOIN tower tow on t.tower_IDtower= tow.IDtower where idaffair = '" + ddlAffair.SelectedValue +
                    "' and IDTower = '" + ddlTower.SelectedValue + "'";
                ddlTeam.Items.Clear();
                fillDropDownList("", sQuery, "ddlTeam");
                ddlTeam.Items.Add("Select the team");
                ddlTeam.SelectedValue = "Select the team";
                displayControls(true, true, true, false, false, false);
            }
            else
            {
                displayControls(true, true, false, false, false, false);
            }
        }
     
        protected void ddlTeam_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlTeam.SelectedValue != "Select the team")
            {
                sQuery = "SELECT designationbu, idBusinessUnit FROM affair a " +
                    "JOIN poste p on a.idaffair= p.affair_idaffair " +
                    "JOIN team t on p.team_idteam= t.idteam " +
                    "JOIN tower tow on t.tower_IDtower= tow.IDtower " +
                    "JOIN BusinessUnit bu on bu.idbusinessunit = p.businessunit_idbusinessunit " +
                    "where idaffair = '" + ddlAffair.SelectedValue +
                    "' and IDTower = '" + ddlTower.SelectedValue + "' and idTeam = '" + ddlTeam.SelectedValue + "'";
                ddlBU.Items.Clear();
                fillDropDownList("", sQuery, "ddlBU");
                ddlBU.Items.Add("Select the business unit");
                ddlBU.SelectedValue = "Select the business unit";
                displayControls(true, true, true, true, false, false);
            }
            else
            {
                displayControls(true, true, true, false, false, false);
            }
        }
     
        protected void ddlBU_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlTeam.SelectedValue != "Select the business unit")
            {
                sQuery = "SELECT designationposte, idPoste FROM affair a " +
                    "JOIN poste p on a.idaffair= p.affair_idaffair " +
                    "JOIN team t on p.team_idteam= t.idteam " +
                    "JOIN tower tow on t.tower_IDtower= tow.IDtower " +
                    "JOIN BusinessUnit bu on bu.idbusinessunit = p.businessunit_idbusinessunit " +
                    "where idaffair = '" + ddlAffair.SelectedValue + "' and idbusinessunit = ' " + ddlBU.SelectedValue +
                    "' and IDTower = '" + ddlTower.SelectedValue + "' and idTeam = '" + ddlTeam.SelectedValue + "'";
                ddlPosition.Items.Clear();
                fillDropDownList("", sQuery, "ddlPosition");
                ddlPosition.Items.Add("Select the position");
                ddlPosition.SelectedValue = "Select the position";
                displayControls(true, true, true, true, true, false);
            }
            else
            {
                displayControls(true, true, true, true, false, false);
            }
        }
     
        protected void ddlPosition_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlPosition.SelectedValue != "Select the position")
            {
                displayControls(true, true, true, true, true, true);
            }
            else
            {
                displayControls(true, true, true, true, true, false);
            }
        }
     
        protected void CalendarStartTeam_SelectionChanged(object sender, EventArgs e)
        {
            tbStartDateTeam.Text = CalendarStartTeam.SelectedDate.ToShortDateString();
            CalendarStartTeam.Visible = false;
        }
     
        protected void ImageCalendarStartTeam_Click(object sender, ImageClickEventArgs e)
        {
            if (CalendarStartTeam.Visible)
                CalendarStartTeam.Visible = false;
            else
                CalendarStartTeam.Visible = true;
        }
     
        protected void CalendarEndTeam_SelectionChanged(object sender, EventArgs e)
        {
            tbEndDateTeam.Text = CalendarEndTeam.SelectedDate.ToShortDateString();
            CalendarEndTeam.Visible = false;
        }
     
        protected void ImageCalendarEndTeam_Click(object sender, ImageClickEventArgs e)
        {
            if (CalendarEndTeam.Visible)
                CalendarEndTeam.Visible = false;
            else
                CalendarEndTeam.Visible = true;
        }
     
        public void displayControls(Boolean affair, Boolean tower, Boolean team, Boolean BU, Boolean position, Boolean other)
        {
            lbAffair.Visible = affair;
            ddlAffair.Visible = affair;
            lbTower.Visible = tower;
            ddlTower.Visible = tower;
            lbTeam.Visible = team;
            ddlTeam.Visible = team;
            lbBU.Visible = BU;
            ddlBU.Visible = BU;
            lbPosition.Visible = position;
            ddlPosition.Visible = position;
     
            displayOtherControls(other);
        }
     
        protected void displayOtherControls(Boolean other)
        {
     
        }
        protected void ddlActualCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
     
        }
     
        protected void ddlProposedCategory_SelectedIndexChanged(object sender, EventArgs e)
        {
     
        }
    }
    Merci

    Il s'agit de code behind sur un usercontrol

  2. #2
    Membre expérimenté
    Homme Profil pro
    Inscrit en
    Juillet 2007
    Messages
    1 277
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Réunion

    Informations forums :
    Inscription : Juillet 2007
    Messages : 1 277
    Points : 1 521
    Points
    1 521
    Par défaut
    Normal, tu es dans un UserControl.

    Tu essayes de faire quoi exactement là ? parce que c'est un non sens.

  3. #3
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2007
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 375
    Points : 154
    Points
    154
    Par défaut
    Il n'y a pas de page load dans un usercontrol ?

    J'essaie de faire des choses propres qui marchent avec SharePoint

  4. #4
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2007
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 375
    Points : 154
    Points
    154
    Par défaut
    Comment je peux appeler une fonction de mon usercontrol dans ma page aspx ?

    J'ai essayé FindControl, mais il me génère des erreurs (différentes erreurs suivant comme je l'écris, donc je ne les postent pas)
    Je pense avoir un problème de déclaration.
    Je dois le déclarer comme un UserControl ou autrement ?

  5. #5
    Rédacteur
    Avatar de Louis-Guillaume Morand
    Homme Profil pro
    Cloud Architect
    Inscrit en
    Mars 2003
    Messages
    10 839
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hauts de Seine (Île de France)

    Informations professionnelles :
    Activité : Cloud Architect
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Mars 2003
    Messages : 10 839
    Points : 28 252
    Points
    28 252
    Par défaut
    Citation Envoyé par Kaidan Voir le message
    Normal, tu es dans un UserControl.

    Tu essayes de faire quoi exactement là ? parce que c'est un non sens.
    attention à pas confondre UserControl, compositeControl, etc
    pour le reste, le Page_Load se declenche tres bien sur mes usercontrols moi


    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
     public partial class exporter : System.Web.UI.UserControl
        {
            private String gridID;
     
            [IDReferenceProperty(typeof(String))]
            [Description("ID of the UltraWebGrid to control"), Category("TAD")]
            public String Grid
            {
                get
                {
                    return this.gridID;
                }
                set
                {
                    this.gridID = value;
                }
            }
     
            protected void Page_Load(object sender, EventArgs e)
            {
                if (String.IsNullOrEmpty(this.gridID))
                {
                    this.exportContainer.Visible = false;
                }
            }
    moi c'est Louis-Guillaume, ni Louis, ni Guillaume mais Louis-Guillaume et je n'aide pas ceux qui écorchent mon nom

  6. #6
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2007
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 375
    Points : 154
    Points
    154
    Par défaut
    Je ne comprends pas.
    Le page_load de ma page aspx fonctionne bien, mais pas ceux de mes usercontrols

    Voila comment mes user controls sont déclarés, il y a peut etre un problème ici
    <ucosition id="Pos" runat="server"/>

    Il sont bien affichés sur ma page, répondent bien, mais pas de page_load

  7. #7
    Membre expert
    Avatar de Pongten
    Homme Profil pro
    IT Analyst & Software Developer
    Inscrit en
    Juin 2002
    Messages
    1 173
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : Belgique

    Informations professionnelles :
    Activité : IT Analyst & Software Developer
    Secteur : Communication - Médias

    Informations forums :
    Inscription : Juin 2002
    Messages : 1 173
    Points : 3 543
    Points
    3 543
    Par défaut
    Comme tu utilise la Page_Load, plutôt que d'overrider la méthode OnLoad, il te faut vérifier que la directive AutoEventWireup="true" est bien présente dans la page.
    Si ton problème a une solution, rien ne sert de t'inquiéter..
    Si il n'en a pas, t'inquiéter ne sert à rien


  8. #8
    Membre habitué
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2007
    Messages
    375
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Loir et Cher (Centre)

    Informations professionnelles :
    Activité : Développeur Java
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 375
    Points : 154
    Points
    154
    Par défaut
    C'était bien cela le problème. Merci beaucoup

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Rentre pas dans le fonction $.ajax
    Par pablofr dans le forum jQuery
    Réponses: 2
    Dernier message: 20/04/2012, 13h58
  2. Fonction qui ne rentre pas dans un IF
    Par stanouu dans le forum PL/SQL
    Réponses: 4
    Dernier message: 11/10/2011, 15h12
  3. ne rentre pas dans la fonction
    Par gilles974 dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 08/06/2009, 16h39
  4. IE ne rentre pas dans ma fonction Javascript
    Par akrogames dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 14/10/2008, 22h34
  5. qu'est ce qui va pas dans cette fonction???
    Par access001 dans le forum PostgreSQL
    Réponses: 3
    Dernier message: 18/04/2006, 13h10

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