Click here to Skip to main content
15,905,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Does anyone know how to watermark a dropdown list so that I can indicate "Select a Name" as the shown value but not have it post to the database as a selection.

I have tried using an item with no value but it keeps coming up with a value anyway, Any time I update my page it always puts a value there. So I add a blank item for the first choice but I want a Select Name there.

What I have tried:

Tried the DropdownList values.
Posted
Updated 26-Feb-16 12:29pm

1 solution

That's not a watermark. It's a "placeholder". ASP.NET controls are not some special thing that browsers handle. ASP.NET markup, <asp... tags, just tell the view engine to emit normal HTML.

Now, there is no standard way of adding a placeholder to a dropdown list. It's just not in the HTML spec. You can fake it, but it's not going to work how you're probably imagining it. On top of that, placeholder support isn't standard across all browsers or browser versions.

You can find an example here[^]. You're probably going to have to do some fudging in ASP.NET to emit the correct HTML, like this[^].
 
Share this answer
 
Comments
faizyab 2009 29-Feb-16 2:15am    
hello are you available this time
Dave Kreskowiak 29-Feb-16 8:38am    
Not while I'm asleep and I also don't take appointments. Everyone here volunteers their time whenever they can.

I'f you've got a question, post your own thread. Do not hijack someone elses.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900