以下是我认为可行的代码
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.watermark{
color: Gray;
background-color: #dddddd;
font-size: smaller;
font-style: italic;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="txtInput" runat="server" AutoPostBack="True"
ontextchanged="txtInput_TextChanged"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="txtInput_TextBoxWatermarkExtender"
runat="server" Enabled="True" TargetControlID="txtInput" CssClass="watermark"
WatermarkText="Some text">
</cc1:TextBoxWatermarkExtender>
但我收到错误Type 'AjaxControlToolkit.TextBoxWatermarkExtender' does not have a public property named 'CssClass'.
TextBoxWatermarkExtender有哪些类与CssClass相同?或者还有另一种方法可以使这项工作吗?
如何解决?
答案 0 :(得分:0)
以下是解决方案TextBoxWatermarkExtender WatermarkCssClass overwrites TextBox CssClass
CssClass
的等效类是WatermarkCssClass
更正后的代码:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.watermark{
color: Gray;
background-color: #dddddd;
font-size: smaller;
font-style: italic;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:TextBox ID="txtInput" runat="server" AutoPostBack="True"
ontextchanged="txtInput_TextChanged"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="txtInput_TextBoxWatermarkExtender"
runat="server" Enabled="True" TargetControlID="txtInput" WatermarkCssClass="watermark"
WatermarkText="Some text">
</cc1:TextBoxWatermarkExtender>
按F5时,输出