Link to home
Start Free TrialLog in
Avatar of bumbling_fool
bumbling_fool

asked on

Create a permanent textbox watermark in ASP.Net

I am trying to create a web user control in ASP.Net that is a textbox with a permanent watermark positioned on the right hand side of the textbox. I want to be able to change the text on the watermark though a property of the user control.

To help make the example clearer, I want to use this textbox control for things like capturing percentages so the % symbol will be permanently displayed on the right hand-side of the textbox so it is clear to the user.

I have created something simple that works by having a label in a separate div that is absolutely positioned....however when I pull it into the main webpage the styles are overridden and it displays incorrectly.

Any thoughts?
ASKER CERTIFIED SOLUTION
Avatar of strickdd
strickdd
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
use css and place a transparent image positioned over the textbox the image will have a higher zorder than the text box and have your logo in the top right...
Doing the transparent image can provide multiple difficulties.

1) In a control you won't be able to specify the text to display on the image. this means a separate image for every text possible
2) Assuming you can dynamically generate this text or you have a specific list of displays that don't change the text will go behind the image and be hard to read if it is the length of the textbox.
3) Assuming the same as number 2, you may run into an issue where the user gets frustrated because he/she can't focus the textbox because he keeps clicking the image.
Avatar of bumbling_fool
bumbling_fool

ASKER

Nice and simple, thanks. Only issue I am still having is that the styles in the main page seem to override the styles in the web control. Any suggestions for this?