473,405 Members | 2,444 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,405 software developers and data experts.

Validating the presence of a property

Hi

Is there a way, in code, to find out if a control in .NET has a property before accessing it? Not only that, but its base class too

I'd like to do something like

if (mycontrol.BaseClass == "textfield" && PropertyExists(mycontrol, "MyProperty")) mycontrol.MyProperty = someValue

Thanks

Skip.
Nov 16 '05 #1
2 782
"Skip" <an*******@discussions.microsoft.com> wrote:
Is there a way, in code, to find out if a control
in .NET has a property before accessing it?
Not only that, but its base class too?


Have a look at the System.Reflection namespace. This allows you to get
meta-information about types at run time.

If you are checking for properties then I think the GetFields method is what
you want.

P.
Nov 16 '05 #2

"Paul E Collins" <fi******************@CL4.org> wrote in message
news:c5**********@sparta.btinternet.com...
"Skip" <an*******@discussions.microsoft.com> wrote:
Is there a way, in code, to find out if a control
in .NET has a property before accessing it?
Not only that, but its base class too?
Have a look at the System.Reflection namespace. This allows you to get
meta-information about types at run time.

If you are checking for properties then I think the GetFields method is
what
you want.


Type.GetProperties() actually.

P.

Nov 16 '05 #3

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

Similar topics

17
by: Sue | last post by:
<html> Is there someone here that can help me validate the period as the fourth from the last character in an email address. There is other information and validation on the form I have to do but...
2
by: Joel | last post by:
Hi! I have a textbox and there is a validating. My question is when I quit (Push Button) I don't want the validating proc to fire, is it possible?
5
by: Astra | last post by:
Hi All I have a <SELECT> for the month (1 .. 12) and a <SELECT> for the year (2004 .... 2020), do you know of any js validation check I can use to check whether these values are older than...
2
by: Skip | last post by:
Hi Is there a way, in code, to find out if a control in .NET has a property before accessing it? Not only that, but its base class too I'd like to do something like if (mycontrol.BaseClass...
0
by: Bradley Bossard via DotNetMonster.com | last post by:
I am having an issue with the .NET framework (or C#) and validating events. I have implemented several validating event handlers for textboxes on a form. When I run the app, the form works...
0
by: Joe | last post by:
Hi For a while now I have been finding postings of problems with the validating event not firing on controls properly. I too had this problem. The event would fire when clicking on another...
2
by: Chris Dunaway | last post by:
I have a form with a textbox and numerous panels, buttons and other controls. I have handled the textbox Validating and Validated events. The textbox will hold a filename. In the validating...
21
by: Darin | last post by:
I have a form w/ a textbox and Cancel button on it. I have a routine to handle textbox.validating, and I have the form setup so the Cancel button is the Cancel button. WHen the user clicks on...
6
by: Ryan | last post by:
I have a windows form that I want to force validation on controls (text boxes) when the user clicks a "Save" button. The only way I've found to do this is to cycle through every control and call...
1
by: Chris | last post by:
I have put two snips of code I use in the body section of my page to validate and submit two forms. The first snip worked fine until I included the second...is the problem the fact variables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
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...

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.