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 :

usercontrol et bouton


Sujet :

ASP.NET

  1. #1
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut usercontrol et bouton
    Bonjour,

    J'ai un usercontrol qui contient des boutons A, B, C et D.
    J'arrive très bien à executer les evenements de mes bouton dans ma page aspx.
    J'arrive aussi à envoyer des valeur à mon usercontrol.
    Mon pb c'est qd je clique sur A, par exemple, il va envoyer au usercontrol la valeur 1 et mon usercontrol met à jour la liste des boutons à afficher (B par exemple), ceci marche très bien.
    Par contre, ensuite qd je clique sur B, il ne se passe rien alors que j'ai crée un onclick sur B

    Qqn a une idée??

  2. #2
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    L'ajout de ton Usercontrol tu le fais en dynamique? et des boutons? Post ton code

    Asp .net ne doit pas retrouver pas qui a envoyé l'événement.

  3. #3
    Membre chevronné
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    360
    Détails du profil
    Informations personnelles :
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2007
    Messages : 360
    Par défaut
    l'evt de B est dans ton aspx ?

    Il faudrait voir comment tu as fais tes abonnements

  4. #4
    Membre confirmé Avatar de bartoumi
    Profil pro
    Inscrit en
    Février 2005
    Messages
    178
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Février 2005
    Messages : 178
    Par défaut
    montre un exemple de code sur comment tu fais !!

  5. #5
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut
    merci d'avoir repondu
    tous mes evenements sont dans l'UC
    Bouton est mon UC
    voilà la partie de mon code, quand je clique sur A, j'envoie etat à l'UC qui affiche bien le bouton B mais je n'arrive à executer l'evenement de B

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
    private void ucBouton_BoutonCreerClick(object sender, EventArgs e)
    {
    ...
    Bouton b = (Bouton)LoadControl("Bouton.ascx",etat,1) ;
    ucBouton.Controls.Clear();
    ucBouton.Controls.Add(b);
    ...
    }
    evenement de B:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    private void ucBouton_BoutonSauverClick(object sender, EventArgs e)
    {
    ...
    }
    je ne rentre pas dedans

  6. #6
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut
    je crois que je change de Uc et dc qd je clique sur B, l'evenement n'est pas le meme
    comment faire???

  7. #7
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    Euh ton loadControl tu le fais dans l'evenment du bouton A??

    Si oui c'est pas bon pour qu'il puisse affecter l'evenemnt a un control il faut que ton button soit présent(recréé) lors du postback.

    Fais plutôt des LoadControl de tes boutons dans ton OnInit et joue avec les propriétés visible.

  8. #8
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut
    mon pb c'est que la variable que j'envoie à mon Uc, je le fais dans l'evenement de A
    et c'est la valeur de cette variable qui decide quels sont les boutons à afficher, donc qd je le met dans l'evenement de A ça marche très bien
    par contre, l'evenement de B n'est jamais execute qd j'appuie sur B
    code de l'uc
    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
     
    public class Bouton : System.Web.UI.UserControl
    	{
    		protected System.Web.UI.WebControls.Button bt_creer;
    		protected System.Web.UI.WebControls.Button bt_save;
    		protected System.Web.UI.WebControls.Button bt_t_analyse;
    		protected System.Web.UI.WebControls.Button bt_t_valide;
    		protected System.Web.UI.WebControls.Button bt_valider;
    		protected System.Web.UI.WebControls.Button bt_annuler;
    		protected GestionWorkflow gw = new GestionWorkflow();
    		protected System.Web.UI.WebControls.Label lbl_text;
    		protected GestionBilans gb = new GestionBilans();
    		protected int etat=0;
     
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonCreerClick;
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonAnnulerClick;
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonSauverClick;
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonTAnalyserClick;
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonTValiderClick;
    		[Category("Configuration"), Browsable(true), Description("")]
    		public event EventHandler BoutonValiderClick;
     
    		public Bouton()
    		{
    		}
     
    		public Bouton(string labelText, int howManyTimes)
    		{
    			System.Text.StringBuilder sb = new System.Text.StringBuilder() ;
    			for (int i = 1; i <= howManyTimes; i++)
    			{
    				sb.Append(labelText) ;
    			}
    			etat = int.Parse(sb.ToString());
    		}
     
     
     
    		private void Page_Load(object sender, System.EventArgs e)
    		{
    			AX.ADN.IS.WacSecurity.Principal.WacPrincipal utilisateur
    				= (AX.ADN.IS.WacSecurity.Principal.WacPrincipal)Page.User;
    			String matricule = utilisateur.Identity.Name.ToLower();
    			Session["utilisateur"]= matricule;
     
    			if(etat == 0)
    			{
    				etat_boutons(true,false,false,false,false,true);
    			}
    			if(etat != 0)
    			{
    				for(int i=0;i<gw.ListeAction(matricule,etat).Tables[0].Rows.Count;i++)
    				{
    					if(gw.ListeAction(matricule,etat).Tables[0].Rows[i].ItemArray.GetValue(0).ToString()
    						==ConfigurationSettings.AppSettings["creation"])
    					{
    						etat_boutons(true,false,false,false,false,true);
    					}
    					if(gw.ListeAction(matricule,etat).Tables[0].Rows[i].ItemArray.GetValue(0).ToString()
    						==ConfigurationSettings.AppSettings["enregistrement"])
    					{
    						etat_boutons(false,true,false,false,false,true);
    					}
    					if(gw.ListeAction(matricule,etat).Tables[0].Rows[i].ItemArray.GetValue(0).ToString()
    						==ConfigurationSettings.AppSettings["t_analyse"])
    					{
    						etat_boutons(false,true,true,false,false,true);
    					}
    					if(gw.ListeAction(matricule,etat).Tables[0].Rows[i].ItemArray.GetValue(0).ToString()
    						==ConfigurationSettings.AppSettings["t_validation"])
    					{
    						etat_boutons(false,true,false,true,false,true);
    					}
    					if(gw.ListeAction(matricule,etat).Tables[0].Rows[i].ItemArray.GetValue(0).ToString()
    						==ConfigurationSettings.AppSettings["v_SSI"])
    					{
    						etat_boutons(false,true,false,false,true,true);
    					}
    				}
    			}
    		}
     
    		public void etat_boutons(bool b1,bool b2,bool b3,bool b4, bool b5,bool b6)
    		{
    			bt_creer.Visible = b1;
    			bt_save.Visible = b2;
    			bt_t_analyse.Visible = b3;
    			bt_t_valide.Visible = b4;
    			bt_valider.Visible = b5;
    			bt_annuler.Visible = b6;
    		}
     
    		public void recupListe(DropDownList dl,DataSet ds)
    		{
    			dl.DataSource = ds;
    			dl.DataTextField = "nom";
    			dl.DataValueField ="nom";
    			dl.DataBind();
    		}
     
    		#region Code généré par le Concepteur Web Form
    		override protected void OnInit(EventArgs e)
    		{
    			//
    			// CODEGEN*: Cet appel est requis par le Concepteur Web Form ASP.NET.
    			//
    			InitializeComponent();
    			base.OnInit(e);
    		}
     
    		/// <summary>
    		///		Méthode requise pour la prise en charge du concepteur - ne modifiez pas
    		///		le contenu de cette méthode avec l'éditeur de code.
    		/// </summary>
    		private void InitializeComponent()
    		{
    			this.bt_creer.Click += new System.EventHandler(this.bt_creer_Click);
    			this.bt_save.Click += new System.EventHandler(this.bt_save_Click);
    			this.bt_t_analyse.Click += new System.EventHandler(this.bt_t_analyse_Click);
    			this.bt_t_valide.Click += new System.EventHandler(this.bt_t_valide_Click);
    			this.bt_valider.Click += new System.EventHandler(this.bt_valider_Click);
    			this.bt_annuler.Click += new System.EventHandler(this.bt_annuler_Click);
    			this.Load += new System.EventHandler(this.Page_Load);
     
    		}
    		#endregion
     
    		protected virtual void OnCreerButtonClick(EventArgs e)
    		{
    			if(BoutonCreerClick != null)
    			{
    				BoutonCreerClick(this,e);
    			}
    		}
     
    		protected virtual void OnBoutonAnnulerClick(EventArgs e)
    		{
    			if(BoutonAnnulerClick != null)
    			{
    				BoutonAnnulerClick(this,e);
    			}
    		}
    		protected virtual void OnBoutonSauverClick(EventArgs e)
    		{
    			if(BoutonSauverClick != null)
    			{
    				BoutonSauverClick(this,e);
    			}
    		}
    		protected virtual void OnBoutonTAnalyserClick(EventArgs e)
    		{
    			if(BoutonTAnalyserClick != null)
    			{
    				BoutonTAnalyserClick(this,e);
    			}
    		}
    		protected virtual void OnBoutonTValiderClick(EventArgs e)
    		{
    			if(BoutonTValiderClick != null)
    			{
    				BoutonTValiderClick(this,e);
    			}
    		}
     
    		protected virtual void OnBoutonValiderClick(EventArgs e)
    		{
    			if(BoutonValiderClick != null)
    			{
    				BoutonValiderClick(this,e);
    			}
    		}
     
    		private void bt_creer_Click(object sender, System.EventArgs e)
    		{
    			OnCreerButtonClick(e);
    		}
     
    		private void bt_save_Click(object sender, System.EventArgs e)
    		{
    			OnBoutonSauverClick(e);
    		}
     
    		private void bt_t_analyse_Click(object sender, System.EventArgs e)
    		{
    			OnBoutonTAnalyserClick(e);
    		}
     
    		private void bt_t_valide_Click(object sender, System.EventArgs e)
    		{
    			OnBoutonTValiderClick(e);
    		}
     
    		private void bt_valider_Click(object sender, System.EventArgs e)
    		{
    			OnBoutonValiderClick(e);
    		}
     
    		private void bt_annuler_Click(object sender, System.EventArgs e)
    		{
    			OnBoutonAnnulerClick(e);
    		}
     
     
    	}
    }

  9. #9
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut
    code page
    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
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
     
    public class NouveauBilan : System.Web.UI.Page
    	{
    		protected System.Web.UI.HtmlControls.HtmlInputFile fichier;
    		protected System.Web.UI.WebControls.Button bt_enregistrer;
    		protected System.Web.UI.WebControls.Button bt_annuler;
    		protected System.Web.UI.WebControls.Button bt_transmis;
    		protected System.Web.UI.WebControls.Button bt_creer;
    		protected GestionBilans gb = new GestionBilans();
    		protected GestionWorkflow gw = new GestionWorkflow();
    		protected System.Web.UI.HtmlControls.HtmlInputHidden confirm_sup;
    		protected System.Web.UI.WebControls.Label Label2;
    		protected System.Web.UI.WebControls.Label Label3;
    		protected System.Web.UI.WebControls.Label Label5;
    		protected System.Web.UI.WebControls.Label Label6;
    		protected System.Web.UI.WebControls.Label Label7;
    		protected System.Web.UI.WebControls.Label Label8;
    		protected System.Web.UI.WebControls.Label Label9;
    		protected System.Web.UI.WebControls.Label Label11;
    		protected System.Web.UI.WebControls.Label Label12;
    		protected System.Web.UI.WebControls.Label Label13;
    		protected System.Web.UI.WebControls.Label Label14;
    		protected System.Web.UI.WebControls.Label Label15;
    		protected System.Web.UI.WebControls.CheckBox rex;
    		protected System.Web.UI.WebControls.CheckBox sox;
    		protected System.Web.UI.WebControls.CheckBox cisi;
    		protected System.Web.UI.WebControls.TextBox nom_projet;
    		protected System.Web.UI.WebControls.TextBox nom_createur;
    		protected System.Web.UI.WebControls.TextBox nom_cdpl;
    		protected System.Web.UI.WebControls.TextBox date;
    		protected System.Web.UI.WebControls.DropDownList list_dcs;
    		protected System.Web.UI.WebControls.DropDownList list_sb;
    		protected System.Web.UI.WebControls.TextBox codeRP;
    		protected System.Web.UI.WebControls.TextBox debutRex;
    		protected System.Web.UI.WebControls.TextBox finRex;
    		protected System.Web.UI.WebControls.DropDownList list_DCS;
    		protected System.Web.UI.WebControls.DropDownList list_SB;
    		protected System.Web.UI.WebControls.Label label;
    		protected System.Web.UI.WebControls.CheckBox cmmi;
    		protected System.Web.UI.WebControls.RequiredFieldValidator Require1;
    		protected System.Web.UI.WebControls.RequiredFieldValidator Requiredfieldvalidator1;
    		protected System.Web.UI.WebControls.Label titre;
    		protected Piece p = new Piece();
    		protected System.Web.UI.WebControls.Button bt_ajouter;
    		protected System.Web.UI.WebControls.RadioButtonList pieces;
    		protected System.Web.UI.WebControls.Button bt_dwl;
    		protected System.Web.UI.WebControls.Button bt_supprimer;
    		protected System.Web.UI.WebControls.Panel Panel_pieces;
    		protected System.Web.UI.WebControls.Label Label1;
    		protected System.Web.UI.WebControls.Label etat;
    		protected System.Web.UI.WebControls.Label test;
    		protected System.Web.UI.WebControls.Panel Panel1;
    		protected System.Web.UI.WebControls.Label Label10;
    		protected System.Web.UI.WebControls.PlaceHolder PlaceHolder1;
     
    		public String etat_bilan = "0";
     
    		private void Page_Load(object sender, System.EventArgs e)
    		{		
    			AX.ADN.IS.WacSecurity.Principal.WacPrincipal utilisateur = 
    				(AX.ADN.IS.WacSecurity.Principal.WacPrincipal)Page.User;
    			String matricule = utilisateur.Identity.Name;
    			Session["utilisateur"] = matricule;
    			DateTime d = DateTime.Now;
    			date.Text = Convert.ToString(d);
    			nom_createur.Text = recup_nom(matricule.ToLower());
    			recupListe(list_DCS,gb.ListeDCS());
    			recupListe(list_SB,gb.ListeSB());
     
    			ucBouton.BoutonCreerClick += new EventHandler(ucBouton_BoutonCreerClick);
    			ucBouton.BoutonAnnulerClick += new EventHandler(ucBouton_BoutonAnnulerClick);
    			ucBouton.BoutonSauverClick +=new EventHandler(ucBouton_BoutonSauverClick);
    			ucBouton.BoutonTAnalyserClick += new EventHandler(ucBouton_BoutonTAnalyserClick);
    			ucBouton.BoutonTValiderClick += new EventHandler(ucBouton_BoutonTValiderClick);
    			ucBouton.BoutonValiderClick += new EventHandler(ucBouton_BoutonValiderClick);
     
    			bt_supprimer.Attributes.Add("onClick","return confirmSup();");
    		}
     
    		private String recup_nom(String matricule)
    		{
    			GestionBilans gb = new GestionBilans();
    			for(int i=0;i<gb.ListePersonnes().Tables[0].Rows.Count;i++)
    			{
    				if(gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(0).ToString()==matricule)
    				{
    					return gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(2).ToString()
    						+ " " + gb.ListePersonnes().Tables[0].Rows[i].ItemArray.GetValue(1).ToString();
    				}
    			}
    			return "";
    		}
     
    		public void recupListe(DropDownList dl,DataSet ds)
    		{
    			dl.DataSource = ds;
    			dl.DataTextField = "nom";
    			dl.DataValueField ="nom";
    			dl.DataBind();
    		}
     
    		#region Code généré par le Concepteur Web Form
    		override protected void OnInit(EventArgs e)
    		{
    			EnableViewState = false;
    			InitializeComponent();
    			Bouton ucBouton = (Bouton)LoadControl("Bouton.ascx",etat_bilan,1) ;
    			PlaceHolder1.Controls.Add(ucBouton);
    			base.OnInit(e);
    		}
     
    		/// <summary>
    		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
    		/// le contenu de cette méthode avec l'éditeur de code.
    		/// </summary>
    		private void InitializeComponent()
    		{  
    			this.Load += new System.EventHandler(this.Page_Load);
     
    		}
     
    		#endregion
     
    		private UserControl LoadControl(string UserControlPath, params object[] constructorParameters)
     
    		{        
    			ArrayList constParamTypes = new ArrayList();
    			foreach (object constParam in constructorParameters)
    			{
    				constParamTypes.Add(constParam.GetType()) ;
    			}
    			object[] o = constParamTypes.ToArray();
    			Type[] t = new Type[o.Length];
    			for (int i = 0; i < o.Length; i++)
    			{
    				t[i] = (Type)o[i];
    			}
    			UserControl ctl = Page.LoadControl(UserControlPath) as UserControl;
     
    			// Find the relevant constructor
    			ConstructorInfo constructor = ctl.GetType().BaseType.GetConstructor(t) ;
     
    			//And then call the relevant constructor
    			if (constructor == null)
    			{
    				throw new MemberAccessException("The requested constructor was not found on : " + ctl.GetType().BaseType.ToString()) ;
    			}
    			else
    			{
    				constructor.Invoke(ctl,constructorParameters) ;
    			}
     
    			// Finally return the fully initialized UC
    			return ctl;
    		}
     
    		public static string conv(bool val)
    		{
    			if(val) return "oui";
    			else return "non";
    		}
     
    		private void bt_ajouter_Click(object sender, System.EventArgs e)
    		{
    			string nom_fichier;
    			String matricule = (String)Session["utilisateur"];
    			int idbe = Convert.ToInt32(Session["idbe"]);
    			if  (fichier.PostedFile.FileName.Length != 0) 
    			{
    				string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
    				nom_fichier=fichier.PostedFile.FileName.Substring(fichier.PostedFile.FileName.LastIndexOf(@"\") + 1);
    				p = gb.AjouterPiece(idbe,matricule.ToLower(),nom_fichier);
    				fichier.PostedFile.SaveAs(monchemin + p.Nom_pj);
    				pieces.Items.Add(nom_fichier);
    				pieces.Items[pieces.Items.Count-1].Value = p.Idpj.ToString();
    				Session["idpj"] = p.Idpj;
    				Session["nom_pj"] = p.Nom_pj;
    				Session["list_piece"] = gb.ListePiece(idbe);
    				/*bt_supprimer.Visible = true;
    				bt_dwl.Visible = true;*/
    			}
    		}
     
    		private void bt_supprimer_Click(object sender, System.EventArgs e)
    		{
    			int idpj = Convert.ToInt32(Session["idpj"]);
    			int idbe = Convert.ToInt32(Session["idbe"]);
    			string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
     
    			if(confirm_sup.Value == "ok" && pieces.Items.Count !=0 && pieces.SelectedItem != null)
    			{
                                    File.Delete(monchemin + gb.RecupNomStrockee(idbe,pieces.SelectedItem.Text));
                                    gb.SupprimerPiece(Convert.ToInt32(pieces.SelectedValue));
                                    pieces.Items.Remove(pieces.SelectedItem);
                            }
    		}
     
    		private void bt_dwl_Click(object sender, System.EventArgs e)
    		{
                            string monchemin= ConfigurationSettings.AppSettings["nomchemin"];
                            int idbe = Convert.ToInt32(Session["idbe"]);
                            string filename = System.Configuration.ConfigurationSettings.AppSettings["eSignServer_RootPath"] + monchemin + gb.RecupNomStrockee(idbe,pieces.SelectedItem.Text);
                            System.IO.FileInfo fileInfo = new System.IO.FileInfo(filename);
                            Response.Clear();               
                            Response.AppendHeader("Content-Disposition","attachment; filename="+fileInfo.Name);
                            Response.AppendHeader("Content-Length",fileInfo.Length.ToString());
                            Response.ContentType = "application/octet-stream";
                            Response.WriteFile(fileInfo.FullName);
                            Response.End();
                    }
     
     
    		private void ucBouton_BoutonAnnulerClick(object sender, EventArgs e)
    		{
                            Response.Redirect("Accueil.aspx");
                    }
     
    		private void ucBouton_BoutonCreerClick(object sender, EventArgs e)
    		{
    			String matricule = (String)Session["utilisateur"];
    			Regex rexValideur = new Regex("[a-zA-Z]+");
    			if(rexValideur.IsMatch(nom_projet.Text) && rexValideur.IsMatch(nom_cdpl.Text))
    			{
                                    //epErrorProvider.SetError(nom_projet, "");
                                    int idbe= gb.CreationBilan(matricule.ToLower(),nom_projet.Text,nom_createur.Text,
                                            nom_cdpl.Text,DateTime.Now,list_DCS.SelectedIndex + 1,
                                            list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
                                            cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
                                    codeRP.Text = idbe.ToString();
                                    Session["idbe"] = idbe; 
                                    etat_bilan = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["creation"]),matricule.ToLower()).ToString();
                            }
    		}
     
     
     
    		private void envoie_mail()
    		{
                            MailMessage message=new MailMessage(); 
     
                            message.From="frank.berrih@axa.fr"; 
                            message.To="frank.berrih@axa.fr"; 
                            //if(subject=="analyse")
                                    message.Subject = ConfigurationSettings.AppSettings["subject_analyse"];// + Session["idbe"].ToString;
                            /*if(subject=="analyse")
                                    message.Subject = ConfigurationSettings.AppSettings["subject_analyse"] + Session["idbe"].ToString;*/
                            StringBuilder chaine=new StringBuilder(); 
     
                            chaine.Append("<b>Erreur sur le site</b><br><br>"); 
                            /*chaine.Append("Détails : <br><br>"); 
                            chaine.Append("Date : "+DateTime.Now.Tostring()+"<br><br>"); 
                            chaine.Append("Pile : "+ex.StackTrace.Tostring()+"<br><br>"); 
                            chaine.Append("Source : "+ex.Source.Tostring()+"<br><br>"); 
                            chaine.Append("Url :"+Request.Url.Tostring()); */
     
                            message.BodyFormat=MailFormat.Html; 
                            message.Priority=MailPriority.High; 
                            message.Body=chaine.ToString(); 
     
                            SmtpMail.SmtpServer="localhost"; 
                            SmtpMail.Send(message); 
                    }
    		private void ucBouton_BoutonTAnalyserClick(object sender, EventArgs e)
    		{
                            envoie_mail();
                    }
     
    		private void ucBouton_BoutonTValiderClick(object sender, EventArgs e)
    		{
     
                    }
     
    		private void ucBouton_BoutonValiderClick(object sender, EventArgs e)
    		{
     
                    }
     
    		private void b_BoutonSauverClick(object sender, EventArgs e)
    		{
                            String matricule = (String)Session["utilisateur"];
                            int idbe = Convert.ToInt32(Session["idbe"]);
                            gb.ModifierBilan(idbe,nom_projet.Text,nom_cdpl.Text,list_DCS.SelectedIndex + 1,
                                    list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
                                    cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
                            String etat = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["enregistrement"]),matricule.ToLower()).ToString();
                            /*Bouton b1 = (Bouton)LoadControl("Bouton.ascx",etat,1) ;
                            //ucBouton.Controls.Clear();
                            ucBouton.Controls.Add(b1);*/
                    }
     
    		private void ucBouton_BoutonSauverClick(object sender, EventArgs e)
    		{
                            String matricule = (String)Session["utilisateur"];
                            int idbe = Convert.ToInt32(Session["idbe"]);
                            gb.ModifierBilan(idbe,nom_projet.Text,nom_cdpl.Text,list_DCS.SelectedIndex + 1,
                                    list_SB.SelectedIndex + 1,1,codeRP.Text,sox.Checked,
                                    cisi.Checked,cmmi.Checked,DateTime.Now,DateTime.Now);
                            String etat = gw.ChangementEtat(idbe,Convert.ToInt32(ConfigurationSettings.AppSettings["enregistrement"]),matricule.ToLower()).ToString();
                    }
    	}
    }

  10. #10
    Membre averti
    Inscrit en
    Janvier 2007
    Messages
    43
    Détails du profil
    Informations forums :
    Inscription : Janvier 2007
    Messages : 43
    Par défaut
    bouton A = bouton créer
    bouton B bouton sauver

  11. #11
    Membre chevronné
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Novembre 2004
    Messages
    417
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 43
    Localisation : France

    Informations professionnelles :
    Activité : Développeur .NET
    Secteur : Finance

    Informations forums :
    Inscription : Novembre 2004
    Messages : 417
    Par défaut
    C'est sur que si dans ta classe Bouton tu change la variable etat dans l'evenement du bouton tu va avoir un probléme car si tu regarde en debug tu vas tjs rentre dans la condition etat == 0.

    Par contre ast tu vraiment besoin de toute cette machinerie pour afficher et cacher des boutons?

Discussions similaires

  1. [Style] Changer le style d'un bouton faisant partie d'un UserControl
    Par Yamigarasu31 dans le forum Windows Presentation Foundation
    Réponses: 7
    Dernier message: 06/04/2011, 21h21
  2. Réponses: 5
    Dernier message: 28/09/2010, 16h57
  3. [visual studio express][c#] usercontrol (bouton + label)
    Par gouroupasdebol dans le forum C#
    Réponses: 3
    Dernier message: 23/10/2009, 08h38
  4. [C#] UserControl qui reagit comme un bouton
    Par 5:35pm dans le forum Windows Forms
    Réponses: 1
    Dernier message: 25/05/2006, 05h00
  5. [VB.Net] usercontrol static et bouton dynamique
    Par krest dans le forum ASP.NET
    Réponses: 19
    Dernier message: 26/07/2005, 17h43

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