Stop Using DatePart for Formatting Dates!

If you’re still formatting dates as such:

lblDate.text = datepart(“d”,Now) & “/” & datepartt(“m”,now) &
“/” & datepart(“yyyy”,now)

then stop this instant!  Step away from the keyboard and no one gets
hurt.

There are better ways in ASP.NET to format dates.  You could replace the
above line of code with:

lblDate.text = getdate().tostring(“MM/dd/yyyy”)

and end up with exactly what you needed.  ASP.NET is full of great
format strings.  Remmeber the old FormatCurrency(MyCash) command?  You
can replace that with MyCash.ToString(“C”).  Download the .NET 2.0 SDK and
look up “formatting strings”; you’ll find all these goodies in
there.

Web Application Settings in ASP.NET 2.0

My latest ASP Alliance article has been published:



ASP.NET 2.0 brought about a number of improvements in the way configuration settings are stored and accessed. Several new configuration sections have been added to the web.config schema, settings can be updated via code, and can be more easily encrypted and decrypted than before. In this article, Richard examines these new features with the help of code samples.


Read it at http://aspalliance.com/820.


 

EZWeb Quick Start

If you’re reading this blog, you’re probably the IT manager for for family
and circle of friends.  The trick to being the IT manager for this group is
to maximize their benefit, while minimizing your own pain.  In such a role,
I needed something “simple and easy”, and one thing I checked out was Jeffrey
Palermo’s EZWeb
.

Installation was a snap–download
a ZIP from GotDotNet
, and extract the contents.  Create an IIS
virtual directory, drop the extracted files into the virtual dir, and grant the
ASPNET (or Network Service if Win2K3) user Modify permissions on the directory
(documentation says Full Control, but I haven’t had any problems with
Modify).  Once this is done, browse to your new virtual dir.

The first thing you’ll see is the welcome page below

Click the [sign in] link, and you’ll get the usual login box.  Log in
with the admin credentials (admin/ezweb, in case you didn’t read the welcome
page)

Once you’ve logged in, you’ll see the menu has added some administrative
tasks.

Your site consists of only the Home page right now.  To add a page,
click on the Manage Page link in the menu.  You’ll be taken to the Page
Administration.

To create a new page, click the Add button in the “Children and Hyperlinks”
section.  You’ll be prompted to enter the title of the new page, and if the
page should open in the same window (Target = Self), or a new window
(Target=Blank); if you’re not using frames, the other options won’t matter.

Click the Update button to save the new page.  You’ll stay on the Page
Administration, but you’ll see your new page appear in the menu.

The page title will also appear in the browser’s title bar, as well as the
page title and breadcrumbs in the default skin.

If you click on the menu link to your new page, you’ll have management
options in your menu.

Clicking on the Edit Content link will open a rich text editor, where you can
enter the text to appear on the page.  You can add and format text in
Design mode, or switch to HTML mode to enter HTML code.  Switch modes by
using the tabs in the lower left corner.  When you’re done, click Save in
the lower right corner.

To add an image to your content, you’ll need to upload the images to your
website.  To add them one at a time, you an use the built in File Manager
tool.  The File Manager is right above the Editor, and is minimized by
default.

Click on the Show link to expand the File Manager.

Click the Browse button to find the file you want to upload, then click the
Upload button.  If you’re uploading a file (such as an Excel spreadsheet),
it will be listed in the Files column.  Images, such as GIF or PNG, will be
listed in the Images column.  Note that JPG files are not supported, so
you’ll need to use GIF or PNG files.  After the upload, you’ll receive a
message that your file already exists on the server–I think that’s a bug right
now.

To insert the image, right-click on the image’s file name, and choose Copy
Shortcut.  Then click the Image button in the text editor (looks like
mountains–) to open the Image Editor.  Paste the image path into Image
Source box, add some ALT text, set any other image parameters, and click OK.

You’ll be returned to the text editor, and your image will appear in the
editor window.  As before, when you’re done editing, click Save.

In this application, images, files and content don’t disappear.  For
each page, a new folder is created in the Images, Files and
FilePageConfigProvider directories.  Images and files are stored
accordingly, in the proper folders.

Page content is stored in XML files in the proper folders under
FilePageConfigProvider.

If the day comes where you need a new system, you can either cut and paste
your content out of the XML (provided you don’t have a zillion pages), or a
competent developer can write a widget to read every file and upload the content
into your new system.

DotNetNuke Document Library With Version Control

I was asked the other day if I knew of a DNN document library with version control.  At the time, I didn’t, but I’ve since found one from WillowTree Software.

This is a DNN 3.1.x or later version of the Wrox Document Dontrol (DNN ported) module. This was first offered by Mark Hoskins (KodHeaz), then Robert J Collins (WillowTree Software), then Tam Tran Minh (TTT Company), and lastly (and once again) Robert J Collins (WillowTree Software).
 
You can’t beat the price—it’s free!

Pittsburgh To Get Citywide Wi-Fi This Summer (maybe)

According to an article in today’s
Post-Gazette
:

By the time visitors stream into Pittsburgh for the July All-Star Game,
Mayor Bob O’Connor and Pittsburgh Downtown Partnership CEO Michael Edwards
want them to be able to fire up their laptops and connect to the Internet from
anywhere in the Golden Triangle. The system may tie into another wireless
network the Pirates want to deploy in PNC Park.

That would be the MLB All-Star game, coming to PNC Park this
summer.

Free Online HTML Validator

I’ve used CSE HTML Validator for quite some time.  I started with ther free version, and upgraded to the full version after using it for a while.  They’ve recently released a free online HTML validator, based on their Lite version engine.  Find it at http://onlinewebcheck.com/.  You can submit the URL of a page, upload a page, or paste in a snippet.  Very cool, and you can’t beat the price.

cache-control: no store to prevent page review

In my article on Preventing Page Review After Logout With Forms Authentication, I talked about several HTTP headers that can be used to direct browsers not to cache pages locally.  In one comment, a reader said they had used the article’s code, but Firefox was still caching pages.  Another reader left a comment about using the “cache-control: no-store” header to prevent Firefox from caching pages.  If you see that Firefox is caching secured pages, try adding this header to your pages.  If possible, add it to your master page or page template.


ASP.NET, you can set this header by using the HttpCachePolicy.SetNoStore method.  Put this in your page_load at the latest.  You can also set this in your page’s HEAD section  by adding the following line of code:


<META HTTP-EQUIV=”CACHE-CONTROL” CONTENT=”NO-CACHE”>


In the IIS control panel, you can set headers to be automatically added to every response.  This is discussed briefly at http://support.microsoft.com/kb/815313/, but if you’re in a shared host environment, you probably don’t have access to the IIS control panel.


The “Cache-Control: No Store” header can cause problems with PDF files in IE 6.  Microsoft has a KB article on this at http://support.microsoft.com/default.aspx?scid=kb;en-us;812935.  File downloads via SSL may also beimpacted if you use this header; see http://support.microsoft.com/?kbid=323308 for more details.  This second article involves a registry edit.


Also, remember that browsers need to cache image files if you’re using image rollovers, so be careful where you use any of these headers.  You might mess up your menu.