Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4614664
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:43:55+00:00 2026-05-22T01:43:55+00:00

i want to validate the control myself. So i put a label and a

  • 0

i want to validate the control myself. So i put a label and a condition when i press the button.

 protected void sendButton1_Click(object sender, EventArgs e)
{
    if (QuestionDetailsTextBox2.Text.Length > 5000)
    {
        QuestionDetailsTextBox2.Text = "You cant enter more than 5000 characters";
    }
    else if(QuestionTextBox1.Text.Length > 100)
    {
        QuestionDetailsTextBox2.Text = "You cant enter more than 100 characters";
    }
    else if (checkValidation())
    {

        QuestionTextBox1.BorderColor = System.Drawing.Color.Red;
    }
    else
    {
        Response.Redirect("AnswerQuestion.aspx");
    }
}

i added a regular expression validater. But i also did this:

  protected void topicDropDownMenu_SelectedIndexChanged1(object sender, EventArgs e)
{
    SubTopicDropDownList.Items.Clear();

    string[] chosenItem = topic[topicDropDownMenu.SelectedItem.Value];

    foreach (string item in chosenItem)
    {
        SubTopicDropDownList.Items.Add(item);
    }

}

Again, i need to press the button twice so that it would redirect me :(… ajax is still necessary?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:43:55+00:00Added an answer on May 22, 2026 at 1:43 am

    If you want an immediate response you will have to move your validation logic to the client. This usually means you write your validation logic in javascript and call it from the client side click event of the button or change event of the textbox before processing the postback events.

    Doing your checks in code behind requires a round trip to the server. Whether you do it this way and postback the full page or use ajax and do a partial postback, there is a delay while the data is sent to the server and the client waits for a response. How big of a delay depends on how much data needs to be transferred and network conditions. This is why ajax is generally faster, it gets to send smaller batches of data.

    However you handle the client side validation, it is generally considered a best practice to repeat the validation logic in the code behind. This is to catch any instances where a user has client side scripting disabled.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to validate a condition before doing the next step, but only raise
I want to validate asp FileUpload Control using in asp.net. That should accept only
I want to use the Validator control to validate a FCKEditor rich text control.
I've got a treeview control, and have caught its after-label-edit event. I want to
I am using Telerik captcha control without textbox and now i want to validate
hi all i want to know that can we validate a control which is
I try to control the jquery.validate errors. I want to show them in a
I want to validate the value a user enters in a text box, so
I want to validate a set of credentials against the domain controller. e.g.: Username:
I want to validate an XML file against an XML Schema file. It is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.