ASP.NET MVC 中的水印文本框
在 ASP.NET MVC 中实现水印文本框控件的最简单方法是什么,互联网上是否有此类控件(可能是 codeplex)。 我认为编写一个扩展 HtmlHelper 并使用 jquery 水印文本框实现是非常简单的。
What is the easiest way to implement watermark textbox control in ASP.NET MVC, are there any such controls on the internet (codeplex maybe).
I suppose it is quite simple to write one extending HtmlHelper and using jquery watermark textbox implementation.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您可以使用如下所示的 Jquery 插件:
Watermark Plugin
提供了一个示例,很简单使用。
You could use a Jquery plugin like the following:
Watermark Plugin
There is a sample provided and is simple to use.
我会使用这个: http://digitalbush.com/projects/watermark-input-plugin /
I would use this one: http://digitalbush.com/projects/watermark-input-plugin/
在这里使用我的 Mvc Controls 工具包的 TypedTextBox: http://mvccontrolstoolkit.codeplex.com/wikipage?title =键入文本框
Use the TypedTextBox of my Mvc Controls toolkit here: http://mvccontrolstoolkit.codeplex.com/wikipage?title=TypedTextBox
我使用并推荐 ClearField jQuery 插件: http://labs.thesedays.com/projects/jquery/ clearfield/
使用起来非常简单,如下所示(从上面的链接复制并粘贴):
将其放入 HTML 页面标题中:
在页面上的某个位置添加此函数:
您的输入字段可能如下所示:
如果您与 ASP.NET(而不是 MVC)一起使用时,您可能会使用如下所示的 ASP 控件:
对于“将此函数添加到页面上的某处”的部分,您需要确保它位于脚本标记内像这样:
I use and recommend ClearField jQuery plugin: http://labs.thesedays.com/projects/jquery/clearfield/
It's very simple to use as shown here (copied & pasted from link above):
Put this in your HTML pages header:
Add this function somewhere on the page:
Your input field might look like this:
If you were using with ASP.NET (not MVC), you'd possibly be using an ASP control like this:
For the part where it say's "Add this function somewhere on the page", you'd want to make sure it's within script tags like this:
检查我的答案这里
使用这个jquery,你可以在上面显示水印您的文本框。这里我使用图像代替水印。您需要创建水印文本的图像。
Check my ans here
with this jquery you can show watermark on your text box .Here I am using an image in place of watermark.You need to create an image of the watermark text.
您可以使用 AJAX Control Toolkit Watermark 控件。
You can probably use the AJAX Control Tookkit Watermark control.