How do I put a hint/placeholder inside a asp:TextBox? When I say a hint I mean some text which disappears when the user clicks on it. Is there a way to achieve the same using html / css?
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- Adding a timeout to a render function in ReactJS
- 'System.Threading.ThreadAbortException' in
- How to update placeholder text in ng2-smart-table?
Adding placeholder attributes from code-behind:
Or
Adding placeholder attributes from aspx Page
Or
Just write like this:
The
placeholder
attributeYou're looking for the
placeholder
attribute. Use it like any other attribute inside your ASP.net control:Don't bother about your IDE (i.e. Visual Studio) maybe not knowing the attribute. Attributes which are not registered with ASP.net are passed through and rendered as is. So the above code (basically) renders to:
Using
placeholder
in resourcesA fine way of applying the hint to the control is using resources. This way you may have localized hints. Let's say you have an index.aspx file, your App_LocalResources/index.aspx.resx file contains
and your control looks like
the rendered result will look the same as the one in the chapter above.
Add attribute in code behind
Like any other attribute you can add the
placeholder
to theAttributeCollection
:This will work you might some time feel that it is not working due to Intellisence not showing placeholder