Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
628 connectés 

  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  [ASP.NET / C#] Savoir si un contrôle a été initialisé ou non

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

[ASP.NET / C#] Savoir si un contrôle a été initialisé ou non

n°955695
Arjuna
Aircraft Ident.: F-MBSD
Posté le 18-01-2005 à 17:27:22  profilanswer
 

J'ai une classe du style :
 

Code :
  1. public class truc
  2. {
  3.     public TextBox val;
  4.     public DropDownList val2;
  5.     public truc()
  6.     {
  7.     }
  8.     public WebControl getObj()
  9.     {
  10.        // ...
  11.     }
  12. }


 
Je déclare un objet de ce type.
Ensuite, je fais un "monObj.val = new TextBox()"
Et plus tard, je veux faire un "Page.Controls.Add(monObj.getObj())"
 
Et cette méthode "getObj()" doit retrouver d'entre val et val2 lequel a été initialisé.
 
Comment faire ?

mood
Publicité
Posté le 18-01-2005 à 17:27:22  profilanswer
 

n°955697
Arjuna
Aircraft Ident.: F-MBSD
Posté le 18-01-2005 à 17:30:25  profilanswer
 

kelkon :o
 

Code :
  1. public string typObj
  2.  {
  3.   get
  4.   {
  5.    if (_typObj != null)
  6.    {
  7.     return this._typObj.Text;
  8.    }
  9.    else if (_typObj2 != null)
  10.    {
  11.     return this._typObj2.SelectedItem.Value;
  12.    }
  13.   }
  14.   set
  15.   {
  16.    if (_typObj != null)
  17.    {
  18.     this._typObj.Text = value;
  19.    }
  20.    else if (_typObj2 != null)
  21.    {
  22.     this._typObj2.SelectedItem.Selected = false;
  23.     this._typObj2.Items.FindByValue(value).Selected = true;
  24.    }
  25.    this.myObj.typObj = value;
  26.   }
  27.  }


 
(en fait ct pas tout à fait pareil, mais presque ;))


Message édité par Arjuna le 18-01-2005 à 17:32:39

Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  C#/.NET managed

  [ASP.NET / C#] Savoir si un contrôle a été initialisé ou non

 

Sujets relatifs
[ASP/Inet] Execute et OpenURLinstallation du .NET 2003
savoir si un enregistrement existe dejaVB .NET récupérer la position de la souris
DoEvents et VB NETProbleme appli .net strategie de securité du framework .net
Creer un fichier Excel en C# .NETVisual C# .NET et les "cannot copy assembly"
contrôle d'accès[asp] quelle base de données utiliser en asp?
Plus de sujets relatifs à : [ASP.NET / C#] Savoir si un contrôle a été initialisé ou non


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR