Using WaterMark Extender with DropDownList in ASP.Net

Last Reply on Aug 06, 2014 01:10 AM By sumanthB

Posted on Aug 05, 2014 06:04 AM

Hi,

How to use watermark(--select--) in dropdownlist.

Posted on Aug 06, 2014 01:10 AM

Hi

I achieved through javascript 

<script type="text/javascript">
    function ddlChange(ddl) {
        if (ddl.selectedIndex == 0) {
            ddl.style.backgroundColor = 'Yellow';
            ddl.options[0].innerText = 'Please select...';
        } else {
            ddl.style.backgroundColor = '';
            ddl.options[0].innerText = '';
        }
    }
</script>

 

<asp:DropDownList ID="DropDownList4" runat="server" Height="19px" Width="154px" onchange="ddlChange(this)">
    <asp:ListItem Value="">... select...</asp:ListItem>
    <asp:ListItem>Beginner</asp:ListItem>
    <asp:ListItem>Proficient</asp:ListItem>
    <asp:ListItem>Expert</asp:ListItem>
</asp:DropDownList>

Thank you