views:

503

answers:

2

I am using asp.net ajax version 1.0 on asp.net 2.0. (I cannot yet upgrade to 3.5)

I had a PageMethod that would get called by Javascript. This worked perfectly until I added an UpdatePanel to another part of the page. Now when I run the page with debug turned on The breakpoint in the pagemethod never gets called. when I look in firebug at what gets returned when the post to the PageMethod is called, I notice that the entire aspx page is returned instead of just the calls value. What have I done?

Here is the Javascript call to the PageMethod:

function EndRequestHandler(sender, args) {
    $('#selectedCHK').change(
        function() {
            var chkedInput = $('#selectedCHK');
            var networkRead = chkedInput[0].checked;
            PageMethods.ChangeSelectedNetworkReadFlag(routeNum, 
                                                      networkRead, 
                                                      function(msg) { alert(msg);  });
        }
    );
}
$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
}

The point of having the EndRequestHandler function called at the end of each request is that the item with the id '#selectedCHK' is inside the update panel and the event needs to get set every time the UpdatePanel is refreshed.

+1  A: 

Try setting the updatemode to conditional on your update panel. Sounds like the update panel is hijacking your events.

<asp:UpdatePanel ID="upMyPanel" UpdateMode="Conditional" runat="server">
RSolberg
Thank you to @RSolberg for your help I din't know about UpdateMode.
minty
+1  A: 

I figured this out and it was a configuration problem. Specifically I needed to add:

<httpModules>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

inside the <system.web> section.

I thought that I had configured the site properly but I decided to go through the documentation step by step.

minty