How to add two CSS Class to control in the code behind?

前端 未结 4 1365
时光取名叫无心
时光取名叫无心 2021-02-12 11:38

I am setting 2 css class in the code behind in ASP.NET

I could either do:

txtBox.Attributes.Add(\"class\", \"myClass1\");
txtBox.Attributes.Add(\"class\"         


        
相关标签:
4条回答
  • 2021-02-12 12:09

    try

    txtBox.Attributes.Add("class", "my_Class1 my_Class2");
    
    0 讨论(0)
  • 2021-02-12 12:15

    The Add method is actually a Put, since it replaces the value behing the key "class". In HTML/css you can have several classes by separating with a space.

    txtBox.Attributes.Add("class", "myClass1 myClass2");
    
    0 讨论(0)
  • 2021-02-12 12:15

    You can also try

    txtBox.CssClass = "myClass1 myClass2";

    0 讨论(0)
  • 2021-02-12 12:21

    try

    txtBox.Attributes.Add("class", "myClass1 myClass2");
    

    I think this will work.

    0 讨论(0)
提交回复
热议问题