473,394 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Using customvalidator control in asp.net 1.1

Hi,

I need to use customvalidator control for calculating datedifference
and need to alert if fromdate is greater than todate.Please let me know
how can i do that using this control in asp.net.
Thanks in advance,
Vishnu

Oct 26 '06 #1
1 1385
Vishnu,

Simply handle the ServerValidate method on the CustomValidator control.
Normally the property for ControlToValidate would be pointing to the
TextBox holding the value you want to check.

However, you want to compare values from 2 controls. There is no
reason you cannot directly refer to the related controls in your event
handler.

Protected Sub cvCompareDates_ServerValidate(ByVal source As Object, _
ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) _
Handles cvCompareDates.ServerValidate
Dim fromDate as String = tbFromDate.Text
Dim toDate as String = tbToDate.Text
If (IsDate(fromDate) AndAlso IsDate(toDate)) Then
args.IsValid = CDate(toDate) < CDate(fromDate)
End If
End Sub

Then you can check Page.IsValid and cvCompareDates.IsValid and trigger
the actions you want to take as appropriate.

Brennan Stehling
http://brennan.offwhite.net/blog/

se****@gmail.com wrote:
Hi,

I need to use customvalidator control for calculating datedifference
and need to alert if fromdate is greater than todate.Please let me know
how can i do that using this control in asp.net.
Thanks in advance,
Vishnu
Oct 26 '06 #2

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

Similar topics

1
by: Jose Fernandez | last post by:
Hola I have this customvalidator <asp:CustomValidator id="ComboValidator" runat="server" ErrorMessage="CustomValidator" /> (The OnServerValidate method is set in Events windows of the Control...
0
by: Jim Heavey | last post by:
Hello, I have added a "CustomValidator" control in in code to a control which is already on the footer. I am running the validation for the control at the server. My problem is that when the...
2
by: Stephen Miller | last post by:
Can the CustomValidator be used to simply report unexpected errors, without requiring Client/Server validation? To explain, say you had a simple text box and button that did a Full-text Search of a...
1
by: Dan Sikorsky | last post by:
I'm getting the following message when I try to add a CustomValidator control to the ValidationSummary to display an error message at runtime, and displaying ex.message in AddValidationControl...
0
by: ghafranabbas | last post by:
This is how you use the customvalidator control in any INamingContainer interface control (Datagrid, DataList, DataRepeater, etc). 1. In the ItemTemplate, place your customvalidator 2. Set the...
1
by: Nathan Sokalski | last post by:
I want to make sure that the SelectedDate property of the Calendar control is later than the current date or that a certain checkbox is selected. I tried to use a CustomValidator control with the...
1
by: David | last post by:
I need help with CustomValidator in 1.1. I added the CustomValidator control and code as per the doc., (See below) However, the code is never executed. Is there an extra switch or setting to...
2
by: lorenzon | last post by:
I have a relatively simple case where I have a form with two fields (call them A and B) which need to be enabled mutually exclusively depending on the state of a drop down. So if drop down is "A"...
3
by: Stan SR | last post by:
Hi, I have a web user control that contains 3 dropdownlists it's a date selector, so one contains the days, one the months and the last the years. Each of them starts with a blank value. I...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...

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.