[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

server side validation

Posted on 2009-02-19
9
Medium Priority
?
173 Views
Last Modified: 2012-05-06
i have a checkbox that I do validationwheather it is checked or not at the server side , by button click, so if user hits the button without checking it, it display message, so than user checks but that message still stays there doesnt dissapear what I need to do for that?
0
Comment
Question by:1jaws
  • 5
  • 3
9 Comments
 
LVL 16

Expert Comment

by:sunithnair
ID: 23685687
Are you using a validation control or just a label to show the error message?
0
 

Author Comment

by:1jaws
ID: 23685708
label.
0
 

Author Comment

by:1jaws
ID: 23685722
because i check in see if that user inside the database, it is i display message you are already in the database...as a label..
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Expert Comment

by:sunithnair
ID: 23685898
Ok then in your pageload event always make the label visible=false and then in the evnt that you check the database and show the label make it visible=true
Page Load
 
lblError.Visible = false;
 
Other Event
 
lblError.Text = "Error message";
lblError.Visible = true;

Open in new window

0
 

Author Comment

by:1jaws
ID: 23685996
I am confused..I have this code  if checkbox is not checked i display this message, ok, so what I need to do? I did make lblcheckterms visible false at the properties, and put lblcheckterms. visible true here in this code but didnt work..
if (chkAgreeToTerms.Checked == false)
        {
             
            lblcheckterms.Text = "Check agreement to continue";
            return;
        }
0
 
LVL 22

Assisted Solution

by:prairiedog
prairiedog earned 400 total points
ID: 23686057
Server-side validation will not fire until the page is submitted. So the first you click the button, the page is submitted and the error lable becomes visible. However, if checking the check box does not cause any postback, then sever does not know it is time to hide the label.
Double-click your Check Box control will generate an event handler for you, then you can add this block of code in it:

if (CheckBox1.Checked)
{
   ErrorLabel.Visible = false;
}

Open in new window

0
 
LVL 16

Accepted Solution

by:
sunithnair earned 1600 total points
ID: 23686123
Try like this
if (chkAgreeToTerms.Checked == false)
        {
             
            lblcheckterms.Text = "Check agreement to continue";
            lblcheckterms.Visible = true;
            return;
        }
 
AND
 
    protected void Page_Load(object sender, EventArgs e)
    {
            lblcheckterms.Visible = false;
    }

Open in new window

0
 

Author Comment

by:1jaws
ID: 23686233
worked either way guys, how about the for the textbox same thing sunith?
0
 

Author Closing Comment

by:1jaws
ID: 31548962
thanks guys it works
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question