Saturday, March 24, 2012

Watermark Extender Validation error

I have a textbox with an ajax watermark extender attached to it. As well as a required feild validator. One button on my page is "CauseValidation = true". Before i applyed the watermark extender the validation check worked perfectly, but now the validation check doesnt work as i think it see`s the watermarktext as text in the textbox, is there any way around this? si!

Hi blink18jew,

Would you mind posting your simple source code here?


sure its like this :

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TestBox" ErrorMessage="ERROR"></asp:RequiredFieldValidator>
<asp:TextBox ID="TestBox" runat="server"></asp:TextBox>
<ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" TargetControlID="TestBox" WatermarkText="Watermarked..." WatermarkCssClass="water" runat="server">
</ajaxToolkit:TextBoxWatermarkExtender>

the watermark seems to ruin the validation checks...si!


Hi blink18jew,

I'm afraid that I cannot reproduce your problem.Here is my test sampe based on yours. It works fine locally.

Aspx:

<%@. Page Language="VB" %><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"></script><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Water Mark</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TestBox" ErrorMessage="ERROR"></asp:RequiredFieldValidator> <asp:TextBox ID="TestBox" runat="server" CausesValidation="true"></asp:TextBox> <ajaxToolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" TargetControlID="TestBox" WatermarkText="Watermarked..." WatermarkCssClass="water" runat="server"> </ajaxToolkit:TextBoxWatermarkExtender> <asp:Button ID="Button1" runat="server" Text="Button" /> </form></body></html>

So would you give us more details including source code or error information? If you can help us reproducing your problem step by step, it will be greatly appreciated.

By the way, did you use your Validator in a UpdatePanel? If yes, maybe you can benefit from this thread: http://forums.asp.net/t/1066821.aspx

Hope it helps.


no worries it was only to get it looking a bit more professional im just not guna use it, but thanks for your time! si!


Hi blink18jew,

Would you do a test with my sample code to find out the exact root cause for this problem ? If we can find the solution, our community members will benefit from our work then.Thanks, Surprise


Tongue Tied it worked... lol, i duno what was going on cos i tryed my olde code and that still didnt work... haha, oh well, ill mark it as answer! thanks.

No comments:

Post a Comment