Change TextBox Border Color Identifying Issue During Validation


<asp:textbox ID="textbox1" runat="server" />
<asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="*" onservervalidate="CustomValidator1_ServerValidate" />
<asp:Button ID="Button1" runat="server" Text="Button" /> 

Code Behind

protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args)
if (textbox1.Text == String.Empty)
textbox1.Style.Add("border", "solid 1px red");
args.IsValid = false;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s