473,839 Members | 1,485 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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\wwwr oot\onepage\bin \onepage.dll"

How can I retrieve TextBox1's text property with reflection? I cannot figure
out which object to pass into textProperty.Ge tValue 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:\i netpub\wwwroot\ onepage\bin\one page.dll")

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

pageFieldInfo = pageType.GetFie ld("_TextBox1" , BindingFlags.In stance Or
BindingFlags.No nPublic)

textBoxType = pageFieldInfo.F ieldType

textProperty = textBoxType.Get Property("Text" , BindingFlags.Pu blic Or
BindingFlags.In stance)

ValueObject = textProperty.Ge tValue(???, Nothing)
Nov 21 '05 #1
0 1316

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

Similar topics

1
7412
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 will be stored in a client-side array currently as that is where it is required. Now to the problem. I've overriden the DataBind Method of my DropDownList and within it have added the code below: Type DataSourceType =...
3
1992
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 following code to get an array containing the fields (wrapped in PropertyInfo objects):
15
8250
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 also a minor change in class Mypropertyinfo, which I have commented out. When using a structure, however, the second call to GetValue returns "Default caption". Can anyone tell me why, and how I can make this work? <code> Imports System
0
417
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 = asm.GetExecutingAssembly Dim oType As Type For Each oType In asm.GetTypes If oType.BaseType.ToString() = "System.Web.UI.Page" Then
1
5958
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()); I get a warning that says p.PropertyType will never be ValueType....and it was right. After stepping through it the types are "System.Boolean" etc... I want to add all integer, string, and boolean types to NameValueCollection,
0
7188
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 had the same problem: system.reflection.propertyinfo.getValue fails with "Object does not match target type." As many of the posts where to old to answer, here's the "solution" : The obj parameter is the object from where propertyinfo gets the...
2
2523
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) host.GetService(typeof(IContainer)); IComponent component1 = container1.Components; PropertyInfo info1 = component1.GetType().GetProperty(this.member.Name);
7
16581
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 C# For indexed properties, instead of Nothing (null) you pass an array of index values. OK, no problem so far.
1
3600
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 problem is arrays or collections which require this syntax: PropertyInfo.GetValue(Object, Object index)
1
4872
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 writing the following types of structure over and over. Is there something I'm missing? Or some 'funky' 3.5 delegate/lambda expression way of doing this? Thanks very much in advance,
0
9854
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9696
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10645
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10290
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9425
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7827
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5681
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
4063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3131
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.