469,950 Members | 1,924 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,950 developers. It's quick & easy.

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 1291
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

Post your reply

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

Similar topics

9 posts views Thread by varois83 | last post: by
7 posts views Thread by Alexandre | last post: by
1 post views Thread by Jon Davis | last post: by
3 posts views Thread by Jon Davis | last post: by
11 posts views Thread by wolf | last post: by
2 posts views Thread by Peter | last post: by
3 posts views Thread by Mike Logan | last post: by
2 posts views Thread by Mick Walker | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.