<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
switch (DropDownList1.SelectedIndex)
{
case 0:
PageManager1.ValueWhenBlankMode = ValueWhenBlankMode.RemoveBoth;
break;
case 1:
PageManager1.ValueWhenBlankMode = ValueWhenBlankMode.RemoveText;
break;
case 2:
PageManager1.ValueWhenBlankMode = ValueWhenBlankMode.RetainBoth;
break;
}
}
</script>
<style type="text/css">
.BlankText
{
background-color: #E0E9E9;
}
</style>
Use this PageManager.ValueWhenBlankMode:
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true">
<asp:ListItem Selected="True">RemoveBoth</asp:ListItem>
<asp:ListItem>RemoveText</asp:ListItem>
<asp:ListItem>RetainBoth</asp:ListItem>
</asp:DropDownList><br/>
<br/>
<des:PageManager ID="PageManager1" runat="server" />
Textual watermark:<br/>
<des:TextBox ID="TextBox1" runat="server" ValueWhenBlank="Fill this in" /><br/><br/>
Style sheet when blank:<br/>
<des:TextBox ID="TextBox2" runat="server" ValueWhenBlankCssClass="BlankText" /><br/><br/>
Both text and style sheet:<br/>
<des:TextBox ID="TextBox3" runat="server" ValueWhenBlank="Fill this in" ValueWhenBlankCssClass="BlankText" /><br/><br/>