Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

Check property

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 29 Feb 2008 21:50 GMT
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
Phil H - 29 Feb 2008 22:38 GMT
> Hello,
>
[quoted text clipped - 11 lines]
> 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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.