473,549 Members | 2,982 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Custom validation For validating dates

I have a textBox Where I type date. I want to validate it. Im using
customValidate controls. I have this function in my code behind page

void DatesValidate(o bject source, ServerValidateE ventArgs e)
{
if (Convert.ToDate Time(e.Value) <= DateTime.Now)
{
e.IsValid = false;
this.lblAddUser s.Text = "The Proxy is already expired";
}
}

<asp:CustomVali dator ID="cvEndDate" runat="server"
OnServerValidat e="DatesValidat e"
ControlToValida te="txtTo" ErrorMessage="e rror"
Display="Dynami c"></asp:CustomValid ator>

It is not working it is giving the follo2ing error
'Proxy.DatesVal idate(object,
System.Web.UI.W ebControls.Serv erValidateEvent Args)' is inaccessible due to
its protection level
Sep 13 '07 #1
1 1529
Add protected keyword to the method, it's private by default if no access
modifier is given.

void DatesValidate.. .

to

protected void DatesValidate.. .

Just note that you can also use CompareValidato r or RangeValidator for
validating date (in case it's simple validation rule). You can give it the
value (ValueToCompare property) to which TextBox's Date is compared.
--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net
"bobby" <bo***@discussi ons.microsoft.c omwrote in message
news:93******** *************** ***********@mic rosoft.com...
>I have a textBox Where I type date. I want to validate it. Im using
customValidate controls. I have this function in my code behind page

void DatesValidate(o bject source, ServerValidateE ventArgs e)
{
if (Convert.ToDate Time(e.Value) <= DateTime.Now)
{
e.IsValid = false;
this.lblAddUser s.Text = "The Proxy is already expired";
}
}

<asp:CustomVali dator ID="cvEndDate" runat="server"
OnServerValidat e="DatesValidat e"
ControlToValida te="txtTo" ErrorMessage="e rror"
Display="Dynami c"></asp:CustomValid ator>

It is not working it is giving the follo2ing error
'Proxy.DatesVal idate(object,
System.Web.UI.W ebControls.Serv erValidateEvent Args)' is inaccessible due to
its protection level

Sep 13 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
3887
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email adresses and so on. I thought it might be a better way to programm an automated, dynamic form validation that works for all kinds of fields, shows the...
21
6201
by: AnnMarie | last post by:
<script language="JavaScript" type="text/javascript"> <!-- function validate(theForm) { var validity = true; // assume valid if(frmComments.name.value=='' && validity == true) { alert('Your full name is required. Please enter your full name!'); validity = false; frmComments.name.focus();
30
3643
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code seems unnecessarily long. For some while, the following approach has been given here :- function ValidDate(y, m, d) { // m = 0..11 ; y m d...
3
1708
by: Vi | last post by:
Hi, I have a form which displays some orders based on dates selected or based on an order number. I have two different buttons for each kind of query, but both buttons call the same method in the code behind page. I'm validating the dates and if they're not ok, I set args.IsValid=false; In the method that retrieves the orders, I check if...
1
1711
by: Stephen Adam | last post by:
Hi there people, I'm creating my own set of self validating text boxes. They all inherit from a base text box which simply contains a required field validator, they then usuallly implement another validator to check they contain number, currencies, dates or whatever. The problem i'm having is with the DateTextBox, I have created my own...
5
3804
by: Micky | last post by:
VB v7.1.3088 NET v1.1.4322 SP1 My mate has a strange problem regarding the ESC key and validation. When he hits the Cancel button on his form, the form does not validate. This is correct behaviour of course. However, he also wants this same behaviour when hitting ESC on the keyboard. It was my understanding that when you assign a button...
9
3126
by: wardy1975 | last post by:
Hi All, Looking for a little expert advice on a few web standards issues. I am currently trying to understand the impact of web standards for a web application I work with. I have been doing a lot of research in the areas of XHTML and WAI compliance, and am attempting to come up with a recommendation for our product in terms of standards...
1
2446
by: criz | last post by:
Hi All, I have a repeater that required a check box on each item in the repeater to be validated against eachother (to check if only one item's checkbox is ticked.) To perform this validation I created a validation control that inherits from BaseValidator and performs server and client side checks and is performing the validation on the...
2
6732
by: John Smith | last post by:
Hello, I have a VB.NET application with a Windows form that have several textboxes fields where I have dates entered. I would like to do a date validation check after the the field is updated, so I' using the leave event. Right now I am creating a 'leave' sub for each of the fields. However, I'd like to simplify that and just call the name...
0
7518
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7446
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7715
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7956
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7808
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6040
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5087
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3498
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3480
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.