CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 9/7/2005 10:46:02 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 18 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
Panties
Asp.Net User
problem with validator within composite control9/7/2005 10:46:02 PM

0/0

I am making a composite control for users to enter dates.  It consists of drop-down lists for the month and day, and a textbox for the year.  I have a method I wrote that checks if the date is valid (i.e., entering Feb 29 is only allowed on leap years), but validating the year textbox itself can be done with just a RangeValidator.  Here is some C# code from my CreateChildControls method:

this.Controls.Add(drpLstMonth);
this.Controls.Add(drpLstDay);
this.Controls.Add(txtYear);
//validator to make sure the user can only enter a 4-digit number for the year
vldtrYear.ControlToValidate = "txtYear";
//other validator properties are set here, removed b/c they are irrelevant to this post
this
.Controls.Add(vldtrYear);

When I run a page that uses an instance of this control, I get an error within the browser saying: Unable to find control id 'txtYear' referenced by the 'ControlToValidate' property of ''.

I thought maybe the control's ID was being renamed at runtime since it's within a composite control, so I changed the line

vldtrYear.ControlToValidate = "txtYear";

to:

vldtrYear.ControlToValidate = Controls[2].ClientID;

It seems I was right about the control's ID being renamed, but that didn't fix the problem. I got the same error message, except 'txtYear' had become 'installDate_ctl02'.
I also find it odd that the error message calls the validator ". instead of  vldtrYear or even installDate_ctl03.

For now I have fixed the problem easily enough with an error message label and a validation method I wrote myself, but I'd like to know how to get regular validators working in composite controls for future reference.

Panties
Asp.Net User
Re: problem with validator within composite control9/8/2005 12:37:41 AM

0/0

I figured it out.  I had to set the ID of txtYear explicitly.  I'm so used to adding controls visually, setting their ID, and then using that ID as the variable name in the codebehind file that I didn't think of it right away.
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
ASP.NET by Example Authors: Steven A. Smith, Pages: 552, Published: 2002
Designing Microsoft ASP.NET Applications Authors: Douglas J. Reilly, Pages: 402, Published: 2001
MULTIMEDIA HYPERMEDIA AND VIRTUAL REALITY: MODELS SYSTEMS AND APPLICATIONS Authors: PIET AUTOR KOMMERS, PETER AUTOR BRUSILOVSKY, INTERNATIONAL CONFERENCE MHVR (1 : 1994 : MOSCOW) AUTOR, Pages: 0, Published: 1996
Pro .NET 2.0 Windows Forms and Custom Controls in C#: From Professional to Expert Authors: Matthew MacDonald, Pages: 1037, Published: 2005
Pro .NET 2.0 Windows Forms and Custom Controls in VB 2005 Authors: Matthew MacDonald, Pages: 1036, Published: 2006
What Causes ADHD?: Understanding What Goes Wrong and Why Authors: Joel T. Nigg, Pages: 422, Published: 2006

Web:
Required field Validation of a CompositeControl - ASP.NET Forums My problem is that I cannot make my composite controls validate as a single control. When I try to use the validation property of a ...
Adding validators to CompositeControl - .NET ASP Adding validators to CompositeControl. Get answers to your questions in our .NET ASP forum. ... Oh, hang on, I think I see the problem. ...
Composite Control Client-Side Validation validator to be outside of the Composite Control so I can easily move ... The problem is i can't seem to make it work Client-Side. ...
Validators in composite control firing prematurely Nov 29, 2005 ... problem is the validators are working to well and seem to be ... composite control. If so, set validator's Enabed to true and manually call ...
CodeProject: An ASP.NET Composite Control for US and UK dates ... A composite custom control and validator for handling US/UK dates; ... The most significant data problem we encountered within English-speaking countries ...
Composite Web Control Example NET server control. A composite control uses child controls to create a user interface (UI) and ... _ Description("Error message for the e-mail validator. ...
Creating Composite Server Controls in ASP.NET 2.0 Jan 25, 2006 ... It doesn't matter which validator control's property we returned for ... the controls within the composite control didn't work as expected, ...
Sasha Sydoruk » HowTo - CompositeControl with a TextBox and a ... Jan 19, 2007 ... The composite control will automatically add the required validators and will create appropriate error messages! Here is the source code: ...
Composite Control Property Setting Problem Talk about Composite Control Property Setting Problem. ... additionally manipulate within the composite, I use private static variables ...
Custom Templated CompositeControl/CompositeControlDesigner Net 2 Login control. Essentially, we would like to have the ability within our CompositeControl/CompositeControlDesigner to ...




Search This Site:










complete newbie looking for help!

checking if membership has expired

create barcodes

troubleshooting forms authentication with active directory

should a button click cause a page_load event?

disadvantages of using eval

vancouver host

when to use new

elearning

what does "http/1.1 500 internal server error" mean?

trying to create the stored procedures for milestones module

is this possible with a master page?

multi level tabs

error on sample from beta.asp.net

setting page variable for time app is open

how to extend formsidentity ?

server application unavailable

gcndotnet

asp .net / c# : multi-user chat system - how can i tell when all users have logged in?

publishing web controls dynamically

unable: vwd.b2 to create memeber/roles with sql.ex.b2/ & web.config nothings too...

connecting to access database

hiding extension types

customizing control types for tags

some difficulties

redirection after login

dnn 3.2.1 uploaded container does not appear in the container menu of a module

asp.net/vb vs vb.net

printer window css

what are the stages that happen when a page loads?

 
All Times Are GMT