Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How do I cast a string into an Object
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00832051
Message ID:
00832823
Views:
12
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?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform