How To Apply Two CssClass In One Textbox RRS feed

  • Question

  • User2033107836 posted


    I Have One Textbox and in that i want to bind two CssClass 

    For example CssClass="Validate" and CssClass="Caluclate"

    How To bind both in one textbox in asp.net 2.0 C#

    Thanking You

    Friday, April 20, 2018 9:41 AM


  • User-369506445 posted


    you can use jquery add several css class to your controls.

    I create a sample that when click on your button the textbox background color and text color be change

    please try below code :

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication2.WebForm2" %>
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
            .backgroundColor {
                background-color: red;
            .textColor {
                color: blue;
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
            $(document).ready(function () {
                $("button").click(function () {
        <form id="form1" runat="server">
        <asp:TextBox runat="server" ID="txt" Text="test css color"></asp:TextBox>
       <button type="button">Button</button>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, April 20, 2018 10:02 AM