Validators for Windows Forms

For those of you who don’t know, those sweet validators we use in WebForms are not available in Windows Forms.  Greg Duncan has a post today that shows how to use an ExtenderProvider to create a RegEx validator in the same vein as the web one.  MVP Billy Hollis had a similar article in 2003, and shows how to create several validators.  For the time-pinched, you can find a current version of the sample at http://dotnetmasters.com/samples.htm.

“How do you know how big to make a field in Crystal Reports?”

Laying out a Crystal Report can be stressful, especially when you’re guessing at how wide to make a field so string data fits.  The problem is, string database fields (such as nvarchar) are measured in characters, but text felds are measured in inches or centimeters.  You could guess at the field width, run the report, see if everything fits, and keep adjusting and running until the entire database field fits the field on your report.


Or you can be smart.


Open your database (or database schema, whatever you are using), and see the maximum length of the data field.  Let’s say we have a varchar(50).  We know the maximum number of characters is 50.  On your report, add a Text Object, and make it kind of wide.  Type in 50 M’s (like this: MMMMMMMMMM…).  Resize the text object until all the M’s are visible.  Drag the database field onto your report, and make it the same width as the 50 M text object.  That is the maximum width your database field will be.


In proportional fonts (such as Times New Roman or Verdana), the uppercase M is typically the widest letter (in monospaced fonts like Courier New, all the letters are the same width).  Using the letter M is an old typesetter trick, and carries over into today’s world.  If you have ever used CSS, and set a font size to ‘1 em’, the ’em’ unit is equivalent to the width of the M in that font face (this is different than the <EM> tag, which italicizes the text).  The ’em’ unit does not have a definite width (such as a cm or in), but is a relative width in each font based on that font’s specification.

OT: If You Really Loved Me, You Wouldn’t Have Sent That To Me

Dear Parent-Spammers, Sibling-Spammers, Friend-Spammers, etc.,


If you really loved me, you wouldn’t have every e-mail message on auto-forward.  Instead, you’d evaluate the content of the message, maybe check out its claims, and discard the crap.  To wit:



  1. There is no spider lurking under toilet seats that will bite your rump.
  2. That isn’t a computer from 1954.  It’s an entry in a Photoshop contest.
  3. Mars was closest to Earth in 2003.  That was two years ago.
  4. Starbucks says they love our troops too, and I need caffeine, so I’m still stopping there.
  5. Everyone’s kidneys are safe.

You can check any of these out at www.snopes.com.  Please do so.


Additionally:



  1. I know it says it’s from your bank, but it’s not from your bank.  Trust me, delete it.
  2. Don’t open the screensaver.  Ever.
  3. Microsoft does not send updates via e-mail.  Never have.
  4. If I don’t personally deliver it on a CD, you shouldn’t install it.  If you do install it, and weird stuff starts happening in the middle of the night, don’t call me.  I’ll hang up on you.  You have been forewarned.
  5. You are far from the first person to send that to me.
  6. I have two dogs.  They are cute.  I do not need any more photos of cute dogs, especially ones whom I do not even know.  I especially do not need several megabytes of photos and/or video in a single e-mail message.
  7. No one from any third world country has any amount of money for you.
  8. You can’t get off their mailing list, and asking them to take you off only makes it worse.
  9. You, and 50 million others, have been specially selected only because they have your e-mail address.  It’s not real, just delete it.

So please, before you mash that Forward button, think about what you’re about to do.


rich

DotNetNuke Error “System.Security.Cryptography.CryptographicException: Bad Data.”

If you receive a Bad Data error when working with DotNetNuke, the problem seems to be with cookies.  The solution is to clear the cookies from your computer, and that should take care of the problem.  It worked for me when I encountered the error.  There is a discussion on this at http://forums.asp.net/975037/ShowPost.aspx, and one of the core team members has a code workaround.


After I cleared my cookies, I changed the name of the FormsAuthentication cookie in my web.config, and the problem has not happened again.


I run DotNetNuke in my main directory (www.rjdudley.com), and have dasBlog set up as a separate application in a subdirectory (www.rjdudley.com/blog).  This error arose after I had logged into my blog site and edited posts or other admin functions, and then tried to log into my DNN portal.  If I manually removed the single cookie for my site from my cookies folder, I could log in with no problems.


Even when I tried setting the path attribute of my forms tag in the web.config for dasBlog, I still got this error.

A Few Clarifications For Mike Drips

Leaving the easy ones aside, here’s a few things Mike Drips might want to know before he writes another article:


1) Hello?  Java and JavaScript are two separate technologies.  JavaScript was independently developed by Netscape, Java was developed by Sun.  JavaScript was actually known as LiveScript until Netscape and Sun entered into a marketing agreement, and rebranded LiveScript as JavaScript.  Netscape’s JavaScript was marketed as a lightweight complement to Sun’s Java on both the server and client side.  That’s right–the ‘Java’ part of ‘JavaScript’ is a marketing gimmick, not a technological bond between the two (however, since both are dreived from some C-variant, you’ll find inevitable similarities).


Microsoft’s JScript almost completely supports Netscape’s JavaScript.  More importantly, both are considered an implementation of ECMAScript, so you can count on a very standard base between the two.  You could make an equal counterargument that Netscape’s JavaScript almost completely supports JScript, but since only ECMAScript is the accepted standard, support for that is all that really matters.


Serious developers know there is more documentation available than just MSDN Library (while we’re on the subject, MSDN Library is head, shoulders, sternum and probably naval above what Netscape and Sun provide for online knowledge).  There’s these things called ‘books’, you see, and you can buy them fairly cheaply.  They are full of really good information.  If you insist on downloading something for free, MS provides a complete JScript reference in its Windows Script Documentation.  You’ll find the latest version at http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en.  This download also includes a VBScript reference.


Here’s the skinny on the lawsuits: they were never about JavaScript.  Not one.  Nor were they about the fact MS built a better Java VM for Windows than Sun did.  They were about the fact that MS called their product a Java Virtual Machine, and infringed on Sun’s trademark.  And, MS wasn’t including non-MS software with its OS, even though anyone who wanted or needed the Java VM could go download it for free whenever they wanted to.  Trademark and market exclusion, not technology.


In response to



Once you get past the shock and horror of encountering the alien JavaScript files, to professionally program SharePoint you also have to deal with CSS, HTML, XML, ASP.Net, Visual Studio.Net, and your choice of C# or VB.Net. That doesn’t include dealing with Windows Server 2003, Active Directory, and the wonderful world of IIS.


All I can say is “OMG!  To program a website, you have to know how to program a website!”  Guess what–if you wanted to program for another platform, you’d still need to know HTML, CSS, XML, Apache and probably PHP and DreamWeaver.  BTW – You forgot FrontPage 2003, which is the recommended editor for SharePoint pages, and SQL Server 2000.  You only need VS if you want to build web parts.


Exactly how ‘alien’ should a technology be that has been around since 1995?  Hello?


2) The next release of SharePoint isn’t timed for Longhorn, it’s timed with Office Wave 12, which is scheduled for late 2006.  SharePoint doesn’t rely on Windows APIs now (the WSS are extensions to the web server, not a native API), so the next OS release is irrelevant.  SPS v3 will run on Win2K3 servers.


3) WSS is not a subset of SPS.  SPS is a superset of technologies that adds functionality on top of WSS.  MS does clear this up at http://www.microsoft.com/sharepoint/overview.mspx#EDAA:



SharePoint Portal Server 2003 is a secure, scalable, enterprise portal server built upon Windows SharePoint Services that you can use to aggregate SharePoint sites, information, and applications in your organization into a single, easy-to-use portal. SharePoint Portal Server 2003 relies on Windows SharePoint Services to provide basic Web hosting and document storage functions, but extends it with additional functions for navigation, search, application integration, and personalization.


This particular page might be more recent than Mike’s SP experience, but that explanation has been around for a long while.


4) You didn’t start with the “Microsoft SharePoint Products and Technologies Resource Kit”, did you?  I guess if you don’t know how to program a website, then yeah, a lot of the SP books will be useless.  That web programming thing might have been something to look into before diving into a SP installation.


5) MS laid out a very solid plan for SharePoint in April at their strategy briefings for CIOs.  It was good.

Very Sweet Open Source DNN Calendar Module

I stumbled across a really sweet calendar module for DotNetNuke today–the AVCalendar from avanced.net.  It’s open source/donationware, and is the best DNN calendar module I’ve found yet.  It supports multiple calendars, which you can arrange as master/child, and an additional calendar list module that lists events from one calendar.  It handles recurring events, and events with limited enrollment.  You can also set a charge for enrollment, and use PayPal for admission.  Weekly and Monthly, as well as etailved views, and there’s an option to add the calendar event to a VCS-compatible calender app such as Outlook.  Definately worth a look.  I’ll be adding this to the BADNUG site shortly as we plan our next events.

Preventing Page Review after Logout with Forms Authentication

My latest ASP Alliance article has been published today:


Preventing Page Review after Logout with Forms Authentication



The inclusion of Forms Authentication in the .NET Framework has been a significant benefit to developers securing web-based applications. While pages can be secured server-side, local caching by browsers and proxy servers may allow a user to review information even after they have logged out. In some cases, this may present a risk to the user’s confidential information. This article discusses three HTTP headers that can be used to prevent local caching of web pages, adding some protection to the user’s data.


Read more: http://aspalliance.com/694

Review: Professional DotNetNuke ASP.NET Portals


My latest ASP Alliance article has been published: Review: Professional DotNetNuke ASP.NET Portals



DotNetNuke is an exciting open-source portal application, full of features and potential. Unlocking the application’s potential through custom modules and configurable skins can involve a steep learning curve. “Professional DotNetNuke ASP.NET Portals” has been written by members of the DotNetNuke Core Team (which manages the overall project), and provides an in-depth discussion on what a developer needs to know to install and develop for the portal.


Read the full review at http://aspalliance.com/693.


Click here to buy the book from Amazon.com