开发者

Errors using Microsoft Ajax Controls

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.开发者_如何学Godtd">

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.


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.


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜