[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Validator issue in ASP.net

Posted on 2006-11-07
4
Medium Priority
?
471 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 1500 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

650 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