What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18723 |  Welcome, Guest!   Register  Login
 Home > Blogs > C# > Use Of Validation without validator In C# ...
Abhi24h

Use Of Validation without validator In C#

 Blog author: Abhi24h | Posted on: 8/23/2012 | Category: C# Blogs | Views: 609 | Status: [Member] | Points: 75 | Alert Moderator   


Here is code of validation of Textbox and dropdown.I have included Register Page image also.
Use Namespace:
using System.Text.RegularExpressions;


protected void create_account_Click(object sender, ImageClickEventArgs e)
    {
        Label1.Visible = true;
        if (txtname.Text == "" || txtmobileno.Text == "" || txtphoneno.Text == "" || txtemail.Text == "")
        {
            Label1.Text = "All Fields are Mandatory";
        }
        else if(drpmemtype.SelectedValue=="Select")
        {
            Label1.Text="Please Click Member Type.";
        }
        else if ( !Regex.IsMatch(txtname.Text, @"^[a-zA-Z''-'\s]{1,40}$"))
        {
            Label1.Text = "Please Enter Your Correct Name.";
        }
        else if (txtaddress.Text == "")
        {
            Label1.Text = "Please Enter Address";
        }
        else if (DDLCity.SelectedValue == "Select")
        {
            Label1.Text = "Please Select City";
        }
        else if (DropLocality.SelectedValue == "Select")
        {
            Label1.Text = "Please Select Locality";
        }
        else if (!Regex.IsMatch(txtmobileno.Text, "^[0-9]{10}$"))
        {
            Label1.Text = "Please Inter Valid Mobile No.";
        }
      
        else if (!Regex.IsMatch(txtphoneno.Text, "^[0-9]{11}$"))
        {
            Label1.Text = "Please Enter Valid Phone No";
        }
        else if (DrpGender.SelectedValue == "Select")
        {
            Label1.Text = "Please Select Gender";
        }
        else if (!Regex.IsMatch(txtemail.Text, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"))
        {
            Label1.Text = "Please Fill Valid Email.";
        }
        else if (txtpassword.Text == "")
        {
            Label1.Text = "Please Fill Password";
        }
      
        else
        {
          <-- Write Here Sql Command For Submission -->
            cmd.Parameters.AddWithValue("@Coumn1", txtname.Text);
            cmd.Parameters.AddWithValue("@Coumn2", txtaddress.Text);
            cmd.Parameters.AddWithValue("@Coumn3", DDLCity.SelectedItem.Text);
          



Abhishek Kumar
http://abhishekkumar.in
Redeemer Engisoft Pvt.Ltd
Found interesting? Add this to:



 More Blogs from Abhi24h

     More ...

    Experience:1 year(s)
    Home page:http://www.abhishekkumar.in
    Member since:Friday, July 13, 2012
    Level:Starter
    Status: [Member]
    Biography:I am Abhishek kumar,have completed B.tech(C.S.E) in 2011,I have a experience of 1 year 6 month in asp.net with C#,MVC and Silverlight.

     Responses

    Sarah
    Posted by: Sarah | Posted on: 9/7/2012 | Level: Starter | Status: [Member] | Points: 15 | Alert Moderator 

    tHeres a course one of the best ones Thanks for all the information,it was very helpful and i really like that you are providing information on .net training ,being enrolled in .net freshers training with projects live training http://www.wiziq.com/course/57-fresher-training-projects i was looking for such .net fresher training to assist me and your information helped me a lot.Really like that you are providing such information . Thanks.

    sarah

    >> Write Response - Respond to this post and get points

    More Blogs

    About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
    General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
    Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2013 8:48:53 PM