首页 > 解决方案 > Asp.net 输入类型 =“文本”与 asp:textbox

问题描述

我是新的 Asp.Net。我有 input type="text" 我也有用于 input[type="text"] 的 css 类。所以我有一个asp:文本框。如何为我的 asp:textbox 编写 css 类,这是一个与输入不同的 css 类?

我的 asp:textbox 从 .login-box input[type=text], input[type=password] 获取属性

<div class="login-box" style="padding:70px 30px">
    <img src="Images\human.png" class="man"/>
    <h1>Login Here</h1>
    <p>Username</p>   
    <input id="username" type="text" name="username" placeholder="Enter Username" runat="server"/>
    <p>Password</p>
    <input type="password" name="password" placeholder="Enter Password"/>
    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click"/>
    <asp:TextBox ID="txtError" CssClass="text-hide" runat="server">Incorrect username or password!</asp:TextBox>
    <a href="#">Forgot Password</a>
</div>

我的style.css如下:

.login-box input {
    width: 100%;
    margin-bottom: 20px;
}
.text-hide {
    height:40px;
    border-color:Transparent;
    background-color:Transparent;
    color:Red;
}
.login-box input[type=text], input[type=password] {
    height: 40px;
    border: 0;
    border-bottom: 1px solid #fff;
    background-color: transparent;
    color: #fff;
    font-size: 16px;
    outline: none;
}

标签: asp.netwebforms

解决方案


使用 CssClass 属性。像这样:

<asp:TextBox ID="txtError" CssClass="text-hide" runat="server">

这将变成:

<input type="text" class="text-hide">

在页面上


推荐阅读