Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Professional For advanced ASP.NET 1.x coders. Beginning-level questions will be redirected to other forums. NOT for "classic" ASP 3 or the newer ASP.NET 2.0 and 3.5
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Professional 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 October 20th, 2007, 10:29 AM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default RegularExpressionvalidator

hi,
How can I associate RequiredFieldValidator and RegularExp
ressionValidator? RegularExpressionValidator doesn't validate a form field unless the form field contains a value. To make the form field required I need to associate it with Requiredfieldvalidator.
please help!
Thank you in advance

here is my code:
<tr>
    <td bgcolor="EEEEEE" align="right">number:</td>
    <td align="left">
    <asp:TextBox id="nrid" runat="server" />
    <asp:Requiredfieldvalidator id="nr_required" runat="Server" controltovalidate="nrid" errormessage="number required" />
    <asp:RegularExpressionValidator runat="server" ControltoVlidate="nrid" ValidsationExpression="[0-9]{8}" errormessage="not valid number" />
    </td>
  </tr>


the above code gives me the following error:
The ControlToValidate property of '' cannot be blank.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: The ControlToValidate property of '' cannot be blank.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[HttpException (0x80004005): The ControlToValidate property of '' cannot be blank.]
   System.Web.UI.WebControls.BaseValidator.ControlPro pertiesValid() +1840442
   System.Web.UI.WebControls.BaseValidator.OnPreRende r(EventArgs e) +33
   System.Web.UI.Control.PreRenderRecursiveInternal() +77
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Control.PreRenderRecursiveInternal() +161
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360


 
Old October 20th, 2007, 01:09 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Your RegEx control defintiion is wrong. This: ControltoVlidate should be: ControlToValidate.

hth

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for:
Beginning Visual C# 2008
Professional Search Engine Optimization with ASP.NET
Professional IIS 7 and ASP.NET Integrated Programming
Wrox Blox: Introduction to Google Gears
Wrox Blox: Create Amazing Custom User Interfaces with WPF and .NET 3.0
================================================== =========
 
Old October 20th, 2007, 01:44 PM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thank you bro. you saved my time!






Similar Threads
Thread Thread Starter Forum Replies Last Post
RegularExpressionValidator collie Visual Studio 2005 0 October 11th, 2007 07:59 AM
RegularExpressionValidator somnath.kartic ASP.NET 1.0 and 1.1 Basics 4 April 3rd, 2006 09:01 PM





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