Solved

Server Validate

Posted on 2012-04-07
2
242 Views
Last Modified: 2012-04-11
Hello:

I am trying to validate a textbox by making the backcolor red when the textbox is null. The required field validator works fine.

<asp:TextBox ID="CityText" Width="200px" runat="server" />

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" Display="Dynamic" ErrorMessage="Required" ControlToValidate="CityText"></asp:RequiredFieldValidator>

<asp:CustomValidator ID="CustomValidator1" runat="server" OnServerValidate="CityText_ServerValidate" ControlToValidate="CityText" ValidateEmptyText="true" Display="Dynamic"></asp:CustomValidator>

        protected void CityText_ServerValidate(object source, ServerValidateEventArgs args)
        {

            if ((CityText.Text == null))
            {
                CityText.BackColor = System.Drawing.Color.Red;
            }

        }
0
Comment
Question by:RecipeDan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Assisted Solution

by:BuggyCoder
BuggyCoder earned 250 total points
ID: 37819804
0
 
LVL 19

Accepted Solution

by:
Manoj Patil earned 250 total points
ID: 37819866
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

705 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