ASP.NET 文本框水印扩展器
我必须向我的文本框添加来自 ajax 控制工具包的 WatermarkExtender
(它已经正确安装)。问题是,当我尝试从工具箱中提取 TextBoxWatermarkExtender
时,Visual studio 2010 不允许我这样做。
这是default.aspx的源代码
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function pageLoad() { }
</script>
<style type="text/css">
.watermark
{
color : Gray;
background-color : #dddddd;
font-size : smaller;
font-style : italic;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 89px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="txtInput" runat="server" text="Enter Date"
AutoPostBack="True" ontextchanged="txtInput_TextChanged"></asp:TextBox>
<asp:TextBox ID="txtEcho" runat="server" ReadOnly="True"></asp:TextBox>
<br />
</div>
</form>
</body>
</html>
这是default.aspx.cs的代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txtInput_TextChanged(object sender, EventArgs e)
{
txtEcho.Text = txtInput.Text;
}
}
I have to add to my textBox a WatermarkExtender
from ajax control toolkit (it is already instaleed properly) . Problem is that when I try pull the TextBoxWatermarkExtender
from the toolbox Visual studio 2010 dont alow's me to do that.
This the source code of default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function pageLoad() { }
</script>
<style type="text/css">
.watermark
{
color : Gray;
background-color : #dddddd;
font-size : smaller;
font-style : italic;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div style="height: 89px">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:TextBox ID="txtInput" runat="server" text="Enter Date"
AutoPostBack="True" ontextchanged="txtInput_TextChanged"></asp:TextBox>
<asp:TextBox ID="txtEcho" runat="server" ReadOnly="True"></asp:TextBox>
<br />
</div>
</form>
</body>
</html>
This is code of default.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txtInput_TextChanged(object sender, EventArgs e)
{
txtEcho.Text = txtInput.Text;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 web.config
页面的源视图中
In web.config
In source view of page
我也遇到了同样的问题;我的 watermarkExtender 在本地工作正常,但在部署服务器上不起作用。我已将最新的 ajax dll 放在服务器上的 bin 文件夹中,但它仍然无法工作。然后在我的 web.config 中添加几行代码后,它解决了我的问题...这是我的 web.config。
I had also the same problem; my watermarkExtender works fine in local, but does not work on deployment server. I had placed the latest ajax dll in my bin folder on server, but it still is not working. Then after few line of code adding in my web.config, it fixed my problem... here is my web.config.