Solved

Validator issue in ASP.net

Posted on 2006-11-07
4
455 Views
Last Modified: 2012-08-13
I have a userControl as shown below. I am using the same usercontrol twice in one of my ASPX pages. How do I add requiredFieldValidator or CustomValidator in my ASPX page where I am using the usercontrol instead of adding in the usercontrol itself.

When I try to add it in my aspx page I am getting this error

Control 'calStart' referenced by the ControlToValidate property of 'cvCalendar' cannot be validated.


<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Calendar.ascx.cs" Inherits="z360.Forms.modules.Utilities.zeewiseCalendar" %>

<table cellpadding=2 cellspacing=2>
<tr>
    <td><asp:TextBox ID="txtCalendar" Width="100" runat=server></asp:TextBox></td>
    <td><a id="hypCalendar" runat=server><img src="../../images/cal.gif" width="16" height="16" border="0" alt="Click Here to Pick up the Date"></a><asp:Label ID="Label1" runat=server Text="*" ForeColor=red Visible=false ></asp:Label></td>    
</tr>

</table>


And when I register and user Control twice in my ASPX page as shown below:

<%@ Register TagPrefix="zw" TagName="Calendar" Src=”Calendar.ascx" %>

Start Date/Time<zw:Calendar ID="calStart" runat=server />
Start Date/Time<zw:Calendar ID="calEnd" runat=server />

And when I add a customFieldvalidator as shown below it is throwing out errors:
<asp:CustomValidator ID="cvCalendar" ControlToValidate="calStart" runat=server OnServerValidate="calendarValidate"></asp:CustomValidator>
0
Comment
Question by:rowmark
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 10

Expert Comment

by:eguilherme
ID: 17895060
havent tried/tested but..

when u put a user control on the page, all of your the controls of the userControl will be renamed like this:

original name:

TextBox1

suppose ur userControl Id at the main page is UserControl1

so ur TextBox1 will be then

UserControl1_TextBox1

so i suppose u gotta make the control to validade to be like that [UserControlID]_[ControlIdToValidade]

not sure tho =/
0
 

Author Comment

by:rowmark
ID: 17895540
No. it doesnt work
0
 
LVL 13

Accepted Solution

by:
jeebukarthikeyan earned 500 total points
ID: 17896251
hi,
In order to be referenced by a validation control, a control must have a validation property. All controls that can be validated have a ValidationPropertyAttribute, which indicates which property should be read for the purposes of validation. If you write your own control, you can make it take part in validation by providing one of these attributes to specify which property to use.

b u d d h a
0
 
LVL 3

Expert Comment

by:rugu_16
ID: 17900999
can you provide detailed error message. Also can you try removing one of u r custom control and then see if it throws error. My point is i dont think it metters if you have 2 same control on the page.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question