Search code examples
iis-7asp.net-ajaxajaxcontroltoolkit

JavaScript events not firing for ASP.NET AJAX Control Toolkit control extenders in IIS 7


[Edited: After cross-testing on a fresh machine and some additional research, this appears to be an issue running in IIS 7. I've read many accounts of problems online but none of the few resolutions I've seen made sense nor (surprise) worked.]

Hi folks, I'm new to ASP.NET AJAX and am having what I assume is a configuration issue.

I've created a new ASP.NET web application and added the ASP.NET AJAX Control Toolkit to my Visual Studio (2008) toolbox.

I have no problem dragging and dropping controls onto new pages and passing validation/debugging. My problem is that none of the control extenders are firing any events when I run through any of the most basic tutorials.

For instance, I'm following the second half of this tutorial: http://www.asp.net/%28S%28ywiyuluxr3qb2dfva1z5lgeg%29%29/learn/Ajax-Control-Toolkit/tutorial-48-cs.aspx

My aspx looks like this:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ShowConfirmButton.aspx.cs" Inherits="ASP.NET_AJAX_Sandbox.ShowConfirmButton" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<!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></head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server" />
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
        <asp:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server" ConfirmText="Really?" Enabled="True" TargetControlID="Button1">
        </asp:ConfirmButtonExtender>
    </div>
    </form>
</body>
</html>

When I run the page, I see my button but clicking it only does a POST.

The bin directory off my project contains System.Web.Ajax.dll and AjaxControlToolkit.dll. I have no problems with the non-extenders I've tried (such as the Editor control). I'm experiencing similar results with the ModalPopupExtender, DropDownExtender, and CalendarExtender.

On inspecting the HTML produced for that page there is a lot of JavaScript inserted, so clearly something's happening (it's rather large to paste here).

This is a brand new sandbox project so I don't believe I have any legacy config issues.

Any thoughts?


Solution

  • Figured it out. Loading the page in IE (instead of FireFox) made it pretty clear there were JavaScript errors on the page.

    The error message I received was:

    Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the AjaxScriptManager in System.Web.Ajax.dll, or use the ToolkitScriptManager in AjaxControlToolkit.dll.

    My solution was to change the ScriptManager in the page from <asp:ScriptManager> to <asp:ToolkitScriptManager>. The base script manager in ASP.NET wasn't able to handle these extensions.