ASP.NET 文本框水印扩展器

发布于 2024-09-17 04:58:14 字数 2043 浏览 8 评论 0原文

我必须向我的文本框添加来自 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;
    }
}

这是来自的printScreen视觉工作室。

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;
    }
}

This is printScreen from visual studio.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

雾里花 2024-09-24 04:58:20

在 web.config

<pages>      
<controls>        
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajt"/>
</controls>
</pages>

页面的源视图中

<ajt:TextBoxWatermarkExtender id="extInput" runat="server" WatermarkText="required" WatermarkCssClass="watermarked" TargetControlID="txtInput"/>   

In web.config

<pages>      
<controls>        
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajt"/>
</controls>
</pages>

In source view of page

<ajt:TextBoxWatermarkExtender id="extInput" runat="server" WatermarkText="required" WatermarkCssClass="watermarked" TargetControlID="txtInput"/>   
沙沙粒小 2024-09-24 04:58:18

我也遇到了同样的问题;我的 watermarkExtender 在本地工作正常,但在部署服务器上不起作用。我已将最新的 ajax dll 放在服务器上的 bin 文件夹中,但它仍然无法工作。然后在我的 web.config 中添加几行代码后,它解决了我的问题...这是我的 web.config。

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <httpRuntime requestValidationMode="2.0" />
    <compilation debug="true">
    </compilation>   
  </system.web>
</configuration>

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.

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <system.web>
    <httpRuntime requestValidationMode="2.0" />
    <compilation debug="true">
    </compilation>   
  </system.web>
</configuration>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文