Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How do I cast a string into an Object
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00832051
Message ID:
00832823
Vues:
13
Eric,

Youc an use Reflection...
Label x = (Label)
WebForm.GetType().GetProperty("Label" + Convert.ToString(i)).GetValue(WebForm,null);

MessageBox.Show(x.Text);
Actually, you'll likely have to use GetField() instead of GetProperty()... Also, I'm not sure, but I think you need to make sure that the scope is at least Protected not private or Reflection won't be able to find it...

+++ Rick ---


>I want to cast
>
>"label" + Convert.ToString(i)
>
>into a System.Windows.Forms.Label so that I can use
>
>MessageBox.Show(x.Text);
>
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform