ASP.NET TextBoxWatermarkExtender
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" TagPrefi开发者_StackOverflow中文版x="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.
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>
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"/>
精彩评论