By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,200 Members | 1,755 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,200 IT Pros & Developers. It's quick & easy.

Accessing textbox via reflection

P: n/a
Hi gang,

I am trying to access the controls on an .ascx via reflection, but cannot seem to figure out which of the "Get..." methods on the type to call to do it.

I have a page with a textbox called "txtFirstName" on it, and what I am trying to do is fill the textbox with data from a domain object. My code to access the textbox is:

Dim dispCompInfo As System.Reflection.FieldInfo
dispCompInfo = Me.GetType.GetField("txtFirstName", Reflection.BindingFlags.NonPublic | Reflection.bindingflags.Instance)

but it keeps coming up with nothing or I get an error that a message is being passed to an object that equals nothing. I have tried other Get... methods on Type, but none seem to yield the textbox. What am I doing wrong?

Also, once I get the textbox, do I need to get property info for the "Text" property in order to set a value in it, or is there some other more convenient/clever way to do that?

Thanks for any input!

Cheers,

Chris
--------------------------------
From: Christopher Burns

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>PoIr0gOUwUGSafD2noiB7w==</Id>
Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.