views:

59

answers:

2

I am trying to add a TextBoxWatermarkExtender control into my ASP.NET 3.5 web application. I followed the tutorial Microsoft supplies here http://www.asp.net/learn/Ajax-Control-Toolkit/tutorial-47-cs.aspx and then I added in the control I wanted. My code looks like this:

<asp:TextBox ID="txtEmailAddress" runat="server" Width="130px"></asp:TextBox>
<cc1:TextBoxWatermarkExtender ID="tbweEmailAddtess" runat="server" TargetControlID="txtEmailAddress" WatermarkText="Email Address">
</cc1:TextBoxWatermarkExtender>

I also added in <asp:ScriptManager ID="smScripts" runat="server" /> as the first tag after my <form> tag.

The code compiles and does not throw any errors that cause the page to not load. I do receive a number of JavaScript errors on the page though.

So after some more research and looking at this errors this is what I found. If I remove the textextender but keep <asp:ScriptManager ID="smScripts" runat="server" /> inside of my on the page I still receive errors. They are: This one is in the page:

//<![CDATA[
Sys.Application.initialize();
//]]> 

This one is in scriptresource.axd and I receive it 2 times.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

Also, I am using URL Rewriting but this is my default.aspx page so I don't know if that plays into it at all.

+1  A: 

There are 2 different versions of the ajaxcontroltoolkit on http://ajaxcontroltoolkit.codeplex.com.

For this sample you need to download the "original Ajax Control Toolkit" at the bottom of the page.

michl86
That is the one I downloaded. I checked the version on the DLL and it is 3.0.30930.28736.
RandomBen
open your page with ie developertools or firebug, and search for the script include tags. could you open these urls? i look's like the MicrosoftAjax.js could not be loaded.
michl86
A: 

After much digging and research I figured it out! I just had to add this code to my global.asax:

routes.Add(new Route("{resource}.axd/{*pathInfo}", new StopRoutingHandler()));

I found the answer at http://msdn.microsoft.com/en-us/library/cc668201.aspx. It doesn't really explain it but after doing some digging I realize what my issue was. It was replacing the code in my webresource.axd file, which is generated by IIS7, with my default not found page NotFound.aspx. While the above code would seem to break things it actually fixes it by stopping the linked code from being overwritten

RandomBen