Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics 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:26 AM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default Associating RegularExpressionValidator and Require

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










Similar Threads
Thread Thread Starter Forum Replies Last Post
RegularExpressionvalidator belete ASP.NET 1.0 and 1.1 Professional 2 October 20th, 2007 01:44 PM
RegularExpressionValidator collie Visual Studio 2005 0 October 11th, 2007 07:59 AM
Associating a recordset field with a control in a osemollie Pro VB Databases 4 July 12th, 2006 04:48 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.