473,411 Members | 2,285 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,411 software developers and data experts.

validate fields after returning from server

3
Response.Write("<textField hint='Enter your First Name' label='First name' name='firstname' size='10' value=''/>");
Response.Write("<textField hint='Enter your Surname' label='Surname' name='surname' size='10' value=''/>");
Response.Write("<textField hint='Enter your House number/name' label='House number/name' size='10' value=''/>");
..................... etc etc

I have asp.net code as above - how do i validate fields firstname,surnmame etc ...after returning back from the client ..using HTTP request and Http Response???

Thankyou
Aug 26 '09 #1
4 1486
PRR
750 Expert 512MB
You need to use Validation controls for your program.
Aug 27 '09 #2
Frinavale
9,735 Expert Mod 8TB
Wow.
You are not using .NET at all right now.
In fact using Response.Write is a horrible idea in your C# or VB.NET code.....

In order to use the validation controls that PRR has suggested you have to actually use ASP.NET elements....you should not use Response.Write like you are.
Aug 27 '09 #3
ash42
3
this is the code i have on page load I would like the data returned from another application and I am accessing the returned data via a querystring ...next task is to validate each field returned ...how do I do this in c#
Expand|Select|Wrap|Line Numbers
  1. public partial class AppSuccessfull : System.Web.UI.Page
  2. {
  3.   protected void Page_Load(object sender, EventArgs e)
  4.   {
  5.  
  6.         ApplicationDetails appQueryString = new ApplicationDetails();
  7.         appQueryString.surname = Request.QueryString["surname"];
  8.         appQueryString.firstname = Request.QueryString["firstname"];
  9.         appQueryString.houseno = Request.QueryString["address"];
  10.         appQueryString.street = Request.QueryString["street"];
  11.         string refNo = Request.QueryString["refNo"];
  12.         appQueryString.postcode = Request.QueryString["postcode"];
  13.  
  14.             }
  15.         }
  16.  
  17. public class validate 
  18.  
  19. {
  20. }
Sep 2 '09 #4
Frinavale
9,735 Expert Mod 8TB
Well instead of having a class named Validate, call it something like... Person or Contact or something.

Have that class validate the data provided to it.

So you'd have something like:
Expand|Select|Wrap|Line Numbers
  1. public partial class AppSuccessfull : System.Web.UI.Page
  2. {
  3.   protected void Page_Load(object sender, EventArgs e)
  4.   {
  5.  
  6.         Contact theContact = new Contact();
  7.         theContact.surname = Request.QueryString["surname"];
  8.         theContact.firstname = Request.QueryString["firstname"];
  9.         theContact.houseno = Request.QueryString["address"];
  10.         theContact.street = Request.QueryString["street"];
  11.         //???? string refNo = Request.QueryString["refNo"];
  12.         theContact.postcode = Request.QueryString["postcode"];
  13.     }
  14.  
  15.     /*...........*/
  16. }
  17.  
  18. private class Contact
  19. {
  20.    private string _surname;
  21.    private string _firstname;
  22.    private string _houseno;
  23.    private string _street;
  24.    private string _postalcode;
  25.  
  26.     public string SurName
  27.     {
  28.         get { return _surname; }
  29.         set { surname = value; }
  30.     }
  31.     public string FirstName
  32.     {
  33.         get { return _surname; }
  34.         set { surname = value; }
  35.     }
  36.     public string HouseNo
  37.     {
  38.         get { return _surname; }
  39.         set { surname = value; }
  40.     }
  41.     public string Street
  42.     {
  43.         get { return _surname; }
  44.         set { surname = value; }
  45.     }
  46.     public string PostalCode
  47.     {
  48.         get { return _surname; }
  49.         set { surname = value; }
  50.     }
  51.  
  52.     public boolean IsValid()
  53.     {
  54.         /*Make sure that all of the information provided is valid here....
  55.           Check to make sure that string lengths are valid etc...
  56.         */
  57.     }
  58.  
  59. }
Sep 2 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: varois83 | last post by:
Hi Newbie here. I have been working on creating a guestbook for my site as practice and am learning a lot. Do you guys validate your forms first on the client with javascript and then on the...
7
by: Alexandre | last post by:
Hi again, What's the best I can do to validate fields like date before send my datas. thx
1
by: Jon Davis | last post by:
This is always returning True, even when fields are empty. Why? private bool ValidatePageOne() { bool ret = true; foreach (Control ctrl in PageOnePanel.Controls) { if...
3
by: Jon Davis | last post by:
This is always returning True, even when fields are empty. Why? private bool ValidatePageOne() { bool ret = true; foreach (Control ctrl in PageOnePanel.Controls) { if...
11
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the...
2
by: Peter | last post by:
I need to validate 4 fields on ASP.NET web page Starting Date __/__/____ Starting Time __:__ Ending Date __/__/____ Ending Time __:__ Staring Date + StartingTime...
3
by: Mike Logan | last post by:
How do I validate messages? If my schema has a simpleType with facets like "minExclusive" and "maxLength" will the .Net framework validate the message before running the web service? This is what...
3
by: c676228 | last post by:
Hi everyone, I just realized that it's so important to validate each string, I mean 'each' before you insert data from asp page into database. I guess some customers just copy data from some...
2
by: Mick Walker | last post by:
Hi, I have a problem that I have been trying to figure for a couple of days, and am wondering if anyone out there would be so kind as to give me a solution. (Deadline time) I am trying to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...
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...
0
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,...
0
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...

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.