473,386 Members | 1,798 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,386 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 1470
"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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.