Solved

Validator issue in ASP.net

Posted on 2006-11-07
4
456 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

707 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