How do you programmatically apply a css class to an asp.net control?

前端 未结 7 1630
余生分开走
余生分开走 2021-01-16 11:46

I\'m wondering how I can apply a CSS class to an ASP.NET Control (TextBox in this case) through the backend in C#. For example:



        
7条回答
  •  别那么骄傲
    2021-01-16 12:17

    You can implement adding cssClass like

    firstName.CssClass = "input left selected";
    

    Or

    make onClick event for textbox

    
    

    Then in code-behind:

    void firstName_Click(Object sender, EventArgs e) {
        MyTextBox.CssClass = "input left selected";
    }
    

提交回复
热议问题