473,748 Members | 2,793 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Validating Data on User Control and Passing Back to the Page

I'm developing a fairly simple user control that has two textboxes for
date/time entry (a from date/time and a to date/time). One of my
requirements is that there should be no button that sets these values (i.e.,
no button to cause a postback). The problem I'm having is that I need a
number of validations to be performed on the data entry, but I don't know
how to do this without having the user control/page posted back to the
server. Basically, I need some way to dynamically validate the user input
without a postback to the server.

The validations that I need are:

** Is the text entered a valid date/time string?
** Is there some value (i.e., cannot be null/empty)?
** The to date/time cannot be before the from date/time
** The time span cannot be greater than 1 year.

Can some one please help me identify ways to do this type of validations of
user input without a postback to the server?

Also, once the data is entered and in the correct format, how do I get those
values off the .ascx and into the page itself, also without a postback?
Therefore, as the user enters data, the data needs to be dynamically
validated and given to the page (and/or put into session state) so that I
can use it later after the user goes on to the next page.

Hope all this makes sense. Any help is greatly appreciated.
Nov 19 '05 #1
1 2903
Hi Panache,

Start with learning about the Validator web controls supplied with ASP.NET.
They handle many of these tasks and let you extend them using the
CustomValidator webcontrol to provide additional logic. They are documented
in the .net docs.

Now for the challenges. You say you have two textboxes two hold 4 pieces of
data: start date, start time, end date, and end time. I'm guessing that
means you demand the user to enter a date + space + time into each text box.
That makes things harder on you and the user.
- For you, you cannot use the built in validators to handle dates. Normally
you use the CompareValidato r with Operator=DataTy peCheck and Type=Date to
determine a correct date and another CompareValidato r with
Operator=LessTh anEquals and Type=Date to compare two date textboxes. Since
you have a time in there, these are not available.
- For your user, they have to learn your syntax of date+space+time . Having
two separate fields not only limits them to entering a single format into
each textbox but also lets you add a popup calendar to the DateTextBox and
other supporting tools to the TimeOfDayTextBo x. For example, keyboard
filtering to omit illegal characters.

I speak from experience as I am the author of one of the most popular web
controls for Date and Time entry, in Peter's Date Package
(http://www.peterblum.com/datecontrols/home.aspx). I encourage you to take a
look at what I've built (its very inexpensive) and see if it helps. Here's
how it answers your questions:
1. There is a separate DateTextBox and TimeOfDayTextBo x that can be
interconnected so your server side code only deals with a single DateTime
value.
2. The DateTextBox has a popup calendar and keyboard filtering. The
TimeOfDayTextBo x has arrows to advance hours and minutes plus keyboard
filtering.
3. To detect a blank field, just use the RequiredFieldVa lidator supplied by
Microsoft.
4. To detect an illegal date format, I supply the DateTextBoxVali dator. For
an illegal time format, I supply a TimeTextBoxVali dator. In addition, these
validators recognize when the two controls are connected and complain if
both are not filled in.
5. I supply a compare validator for From Date+Time and To Date+Time.
6. I supply a difference validator to be sure the number of days between the
dates is not exceeded.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlu m.com
Creator of "Profession al Validation And More" at
http://www.peterblum.com/vam/home.aspx

"panche" <pa****@nospam. com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I'm developing a fairly simple user control that has two textboxes for
date/time entry (a from date/time and a to date/time). One of my
requirements is that there should be no button that sets these values
(i.e.,
no button to cause a postback). The problem I'm having is that I need a
number of validations to be performed on the data entry, but I don't know
how to do this without having the user control/page posted back to the
server. Basically, I need some way to dynamically validate the user input
without a postback to the server.

The validations that I need are:

** Is the text entered a valid date/time string?
** Is there some value (i.e., cannot be null/empty)?
** The to date/time cannot be before the from date/time
** The time span cannot be greater than 1 year.

Can some one please help me identify ways to do this type of validations
of
user input without a postback to the server?

Also, once the data is entered and in the correct format, how do I get
those
values off the .ascx and into the page itself, also without a postback?
Therefore, as the user enters data, the data needs to be dynamically
validated and given to the page (and/or put into session state) so that I
can use it later after the user goes on to the next page.

Hope all this makes sense. Any help is greatly appreciated.

Nov 19 '05 #2

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

Similar topics

3
2043
by: vikaskuk | last post by:
hi all, i am using tabstrip with multipage control in asp.net. i have put some textboxes on the first tab. my requirement is that whenever user makes some changes in any of textbox and moves to next tab without saving this data he should get alert message and should be stopped on current tab itself.
4
2084
by: Al Jones | last post by:
I have an application - an insurance form - which requests personal data on form one. If the user checks auto or homeowner (or both) on the first form I need to collect data from each of these (popup?) forms (Auto and HomeOwner respectively) and then write this collected data to an email message. Passing selected data to the child forms via the url is possible, but I'm certain I'd run into a length problem. Since I still have the parent...
5
2118
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a button and just using the data during postback. Now, however, I've got a WebForm that I'll be working on, and it is going to collect more data than I have collected from the user in the past. I want to be able to attempt to save each part and if...
4
2029
by: bremdevnet | last post by:
I have a ASPX page that loads a custom control. This first custom control is made up of 2 textboxes and a Submit button. The user enters data into the form, presses the Submit button and the ASPX page should either load a new custom control during the postback or (if validation fails) reload the first custom control. I've attached some validation controls without a problem but the client-side validation doesn't seem to be working...even in...
0
2438
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
4
2569
by: Tarun Mistry | last post by:
Hi, i have a page with a user control on it, the uc is a form with a submit button. On submitting, how do I make the call get picked up by the webform the user control is in? Alteratively, is it possible to post to a different .aspx page? Thanks, Taz
17
3860
by: stathis gotsis | last post by:
Hello everyone, I am tying to come up with an elegant way to process some input data that come from a form. When the user hits the 'Submit' button, i want the form to appear again with the already entered valid data filled in and prompt the user to re-enter the non-valid data. If all data is valid, i will forward to an other .php page which enters the data into a database. I tried to do this in the following way: the form always hits...
232
13318
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
5
1740
by: Ludwig | last post by:
I have a user control news.ascx that lists news items, and it has add/edit/delete linkbuttons. This user control is on the default.aspx page together with other user controls. When the edit linkbutton for a news item is clicked, it redirects to another page news.aspx, the news user control is also on this page. Question: when the user clicks the edit linkbutton in the user control
0
8830
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9370
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9247
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8242
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6074
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4874
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3312
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2782
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.