473,324 Members | 2,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

propertyinfo getvalue

I've created a web app named "OnePage" and it has only one page, WebForm1. I
added a web control, TextBox1 and set the Text property of TextBox1 equal
to "Text from TextBox1". I've built the project and the .dll resides at
c:\inetpub\wwwroot\onepage\bin\onepage.dll"

How can I retrieve TextBox1's text property with reflection? I cannot figure
out which object to pass into textProperty.GetValue below. I get the
TargetException: Object does not match target type. TIA.

Dim asm As [Assembly]

Dim pageType As Type

Dim pageFieldInfo As FieldInfo

Dim textBoxType As Type

Dim textProperty As PropertyInfo

Dim ValueObject As Object

asm = [Assembly].LoadFrom("c:\inetpub\wwwroot\onepage\bin\onepage. dll")

pageType = asm.GetType(asm.GetName.Name & "." & "WebForm1", True, True)

pageFieldInfo = pageType.GetField("_TextBox1", BindingFlags.Instance Or
BindingFlags.NonPublic)

textBoxType = pageFieldInfo.FieldType

textProperty = textBoxType.GetProperty("Text", BindingFlags.Public Or
BindingFlags.Instance)

ValueObject = textProperty.GetValue(???, Nothing)
Nov 21 '05 #1
0 1288

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: gt | last post by:
I am trying to replicate the functionality of DataTextField/DataValueFields in an extended DropDownList control that I have created in order to provide a third value for each ListItem. This value...
3
by: Oskar Lundgren | last post by:
I want to iterate over fields declared like this, using reflection (and there are good reasons for that): Protected WithEvents Foo1 As Bar Protected WithEvents Foo2 As Bar .... I use the...
15
by: Charles Law | last post by:
I have adapted the following code from the MSDN help for PropertyInfo SetValue. In the original code, the structure MyStructure is defined as a class MyProperty, and it works as expected. There is...
0
by: Paul | last post by:
I'd like to iterate through the controls on pages within a dll. I can get a page's Controls in a PropertyInfo class but can't extract the ControlsCollection from there. Dim asm As =...
1
by: INeedADip | last post by:
PropertyInfo props = obj.GetType().GetProperties(); foreach (PropertyInfo p in props) if (p.PropertyType is ValueType) this._commonProperties.Add(p.Name, p.GetValue(request, null).ToString()); ...
0
by: SyZLaB | last post by:
I had a problem using system.reflection.propertyinfo.getvalue in vb - and searched a lots of newsgroups and libraries - but none had the solution to my problem - and it also seamed like many others...
2
by: Carlos Rodriguez | last post by:
I have the following function in C#public void Undo(IDesignerHost host) { if (!this.componentName.Equals(string.Empty) && (this.member != null)) { IContainer container1 = (IContainer)...
7
by: Tom Dacon | last post by:
I'm using Reflection to iterate over the properties and fields of an arbitrary object. For non-indexed properties it's pi.GetValue(theObject, Nothing) for VB, or pi.GetValue(theObject, null) for...
1
by: samueltilden | last post by:
I am writing a very generic DumpObject(object Obj) method. I can easily GetType() and GetType().GetProperties(). I can easily PropertyInfo.GetValue(Obj, null) for scalar variables. The...
1
by: damiensawyer | last post by:
Hi, I need to invoke .getvalue and .setvalue on fieldinfo and propetyinfo objects. Even though they're both derived from MemberInfo, they don't share those two methods. I've finding myself...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.