Plunging into .NET Development

Weblog Pieter Gheysens
Microsoft .NET Development - C# - Enterprise Library - Visual Studio 2005 Team System - Compuware DevPartner - ...
 


Saturday, December 30

Check valid email address - client/server

Validation controls in .NET 2.0 provide an easy-to-use mechanism for all common types of standard validation. You can drag and drop for instance the RegularExpressionValidator control on your webform to determine whether the value of an input control matches a pattern defined by a regular expression. Ideal to check a telephone number or an email address. This validation occurs by default on client-side and on server-side.

Lately I needed to create a webpage where an input field was needed where multiple email addresses could be entered, separated with commas. In this particular case, I only provided validation on server-side using the Regex class (namespace System.Text.RegularExpressions).

    public void DoValidationForEmails(string inputString)

    {

      //inputString contains all email addresses, separated with commas

      string separator = ",";

      string[] allEmails = inputString.Split(separator.ToCharArray());

 

      //Regular Expression for validating email addresses

      Regex regularExpression = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");

 

      foreach (string emailAddress in allEmails)

      {

        if (regularExpression.IsMatch(emailAddress))

        {

          //Valid email address

        }

        else

        {

          //Invalid email address

        }

      }

    }


Anyone already done this on client-side as well?

Labels:

Thursday, December 28

Interesting links

Two interesting links on the Internet I haven't seen or heard of before :
  • Alexa Traffic Rankings
    Alexa computes traffic rankings by analyzing the Web usage of millions of Alexa Toolbar users. The information is sorted, sifted, anonymized, counted, and computed, until, finally, we get the traffic rankings shown in the Alexa service.
  • Internet Archive : Wayback Machine
    Want to know how the Google Homepage looked like in 1999? Browse through 85 billion web pages archived from 1996 to a few months ago. To start surfing the Wayback, type in the web address of a site or page where you would like to start, and press enter. Then select from the archived dates available. The resulting pages point to other archived pages at as close a date as possible.

Labels:

Tuesday, December 26

Response.Redirect - ThreadAbortException

The Response.Redirect method is often used in webpages to redirect users to other pages as part of the web application. ASP.NET offers different ways to build redirection into webpages :
  • Using hyperlinks on pages.
  • Configuring cross-page posting, which enables you to specify an alternate target page when the current page is submitted.
  • Redirecting programmatically by forcing the browser to request a different page.
  • Redirecting programmatically by transferring control to a different page in the same Web application.
Recently I saw a lot of exceptions (System.Threading.ThreadAbortException) in the logfile of a web application. It was quickly clear that this was caused by all redirections set in the web application. The third method (see above) was used to programmatically redirect users to other webpages in the web application, but the Response.Redirect method was always used without the optional/overloaded endResponse boolean parameter. This parameter indicates whether execution of the current page should terminate. If not set to false (default = true), the Redirect method will always generate a System.Threading.ThreadAbortException and will immediately stop executing any additional code.

Saturday, December 23

Visual Studio IDE hangs

After installation of DevPartner Studio I noticed that the Visual Studio IDE hangs from time to time. Here's my mail to the DevPartner product support team :
Hello,

the problem described below happened to me already twice on different computers. I would like to know if this is a known bug and if there's a workaround for this issue?

After installation of Visual Studio 2005 Team Suite everything works fine, but after the installation of DevPartner Studio 8.1.313.0, the Visual Studio 2005 environment freezes after certain operations. Actually, the IDE freezes each time after a "progress pop-up" of Visual Studio 2005 was displayed. This behavior only came into play after the installation of DevPartner Studio.
Specific Example :
  • open Visual Studio 2005 Team Suite
  • open Team Explorer and connect to a Team Foundation Server
  • open Team Foundation Source Control and open a solution that's in Source Control
  • edit a random code file
  • undo check-out code file
  • progress bar of undo check-out is briefly displayed
  • IDE freezes
The only option now is to kill the Visual Studio 2005 process and to start over again! So, for each check-in or undo check-out a progress pop-up is briefly displayed and after that Visual Studio 2005 hangs. After an uninstall of DevPartner Studio, everything works fine again ...

Hoping for your quick feedback!

Pieter Gheysens
.NET Consultant
Professional Services Compuware Belgium
Their quick reply :
Hi Pieter,

As it turns out we've seen this before. It is a known bug within TFS. Microsoft has a fix available for this bug. (Microsoft KnowledgeBase #922989)

Customers can call Microsoft Support (800-936-5700), wait for a human being to answer, and specifically mention the fix for KB 922989. (They will email you a download link for the fix.)

Microsoft's thread on the subject can be viewed here.

If you have a trouble reaching Microsoft, there are a couple of ways install DevPartner and still workaround this issue.
  • Don't have a solution open whenever you perform source control operations.
  • Run a second copy of VisualStudio (with no solution opened) for source control.
  • Team Foundation Server is only conflicting with ONE DevPartner module (Code Review); so, if you follow these steps, you will be able to use all DevPartner features except Code Review from within VisualStudio 2005.
    1. shut down VisualStudio
    2. go to your registry (e.g. Start menu, Run, regedit)
    3. navigate to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\8.0\Packages\{05B110B5-B90F-435e-BAB7-A2FC19F9A9E3}
    4. Rename this key by adding 3 dashes in front of the name like this ...\Packages\---{05B110B5-B90F-435e-BAB7-A2FC19F9A9E3}
    Then, when you start VisualStudio again, the CodeReview package won't load. You can re-enable Code Review at any time by removing the dashes and re-booting VisualStudio. Alternately, you can leave Code Review disabled in VisualStudio and still access its functionality using our command line interface. (For information on how to do this, access the Help in VisualStudio 2003 or VS2005 and navigate to DevPartner, Code Review, Running a Review from the Command Line.)
The change in the registry fixed my problem, but I want to stress some important points when you want to tackle this issue yourself :
  • Microsoft has put this fix into their Visual Studio 2005 Service Pack 1 which just came out. At this time the DevPartner Product is not supporting SP1!
  • The new release of DevPartner (v8.1.1) also doesn't support the SP1!

Monday, December 11

VISUG Discussion Event

Just returned from the VISUG event on Exception Handling and Logging. Our discussion event was really interesting. More than 20 people showed up to start up a discussion about Exception Handling & Logging in Enterprise Applications. Good to see that so many people want to share their experiences and are eager to know other opinions! More discussion events will certainly follow after this positive try-out. Thanks Peter for being our moderator/host!

Be sure to register for our next event on December 21 : VISUG Geek Dinner! This will be very interesting as well!