Wrox Programmer Forums
BOOK: Beginning ASP.NET Web Pages with WebMatrix
This is the forum to discuss the Wrox book Beginning ASP.NET Web Pages with WebMatrix by Mike Brind, Imar Spaanjaars ; ISBN: 978-1-1180-5048-4
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET Web Pages with WebMatrix section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old December 21st, 2011, 01:57 PM
Authorized User
Join Date: Aug 2010
Posts: 50
Thanks: 7
Thanked 0 Times in 0 Posts
Default Chapter 4:Reusable function


First I would like to say I really like this book. Thanks.

I am having trouble with the reusable function. The email address is coming out false everything looks okay to me.

@using System.Text.RegularExpressions;

@functions {
    public static bool IsValidEmail(string s)
        string pattern = @"^[\w-\.]+@ ([\w-]+\.)+[\w-]{2,4}$";
        return Regex.IsMatch(s,pattern);
Please help. Thanks.
Old December 22nd, 2011, 05:22 AM
Wrox Author
Join Date: Dec 2011
Posts: 57
Thanks: 1
Thanked 19 Times in 19 Posts

You have a space after the @ sign in your pattern variable. Remove that and it should work.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Reusable Page Templates workidoo BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 6 June 25th, 2008 04:58 PM
How to make GUI reusable in .NET hums .NET Framework 2.0 0 October 20th, 2004 12:09 AM
Need help creating reusable code in a class. jbenson001 ASP.NET 1.x and 2.0 Application Design 1 November 21st, 2003 01:07 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.