PC Review


Reply
Thread Tools Rate Thread

Check property

 
 
shapper
Guest
Posts: n/a
 
      29th Feb 2008
Hello,

Before I add a control I need to check if its CssClass is defined.
Should I use:

If String.IsNullOrEmpty(MyControl.CssClass) Then
....

I am not sure if this is the correct way because the user can set my
mistake MyControl.CssClass = ""

How should I do it?

Thanks,
Miguel
 
Reply With Quote
 
 
 
 
Phil H
Guest
Posts: n/a
 
      29th Feb 2008
On 29 Feb, 21:50, shapper <mdmo...@gmail.com> wrote:
> Hello,
>
> Before I add a control I need to check if its CssClass is defined.
> Should I use:
>
> If String.IsNullOrEmpty(MyControl.CssClass) Then
> ...
>
> I am not sure if this is the correct way because the user can set my
> mistake MyControl.CssClass = ""
>
> How should I do it?
>
> Thanks,
> Miguel


Hi

When MyControl.CssClass = "", the method
String.IsNullOrEmpty(MyControl.CssClass) will return true because the
string is Empty i.e. the property references a string object which has
zero characters (zero length). This is not the same as being Null (or
rather Nothing in VB) when the reference itself is null and the string
object doesn't exist. As the method name implies it returns true in
either case so is a useful way to tell if the CssClass is defined or
not.

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check property value shapper Microsoft ASP .NET 1 30th Oct 2007 07:27 PM
Check Box Property =?Utf-8?B?SmVubmll?= Microsoft Access 16 3rd Jan 2006 03:33 PM
Using a Combo-box to set Check-box property to yes =?Utf-8?B?cmppbnhlZA==?= Microsoft Access 4 29th Dec 2005 05:59 PM
How check BackgroundImage property? VB Programmer Microsoft VB .NET 1 2nd Nov 2005 12:55 AM
check box user property Dale Microsoft Outlook Form Programming 1 13th May 2004 01:27 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:41 AM.