Search code examples
c#.netajaxpopupcontrolextender

PopupControlExtender DynamicServiceMethod giving 500 error


I have looked around, and haven't found a solution to my problem. I have an PopupControlExtender that keeps giving a "Web Service call failed: 500" error instead of showing the popup. I have a datagrid with an OnItemCreate property that works properly to assign a mouseouver and mouseout attribute to an image in a column. Below is the code for the column that contains both the targetControl image as well as the AJAX control itself.

Here is the code for the ajax control:

           <asp:TemplateColumn
            HeaderText="Notes"
            SortExpression="note"
            ItemStyle-VerticalAlign="Top"
            HeaderStyle-HorizontalAlign="Center" 
            HeaderStyle-CssClass="colNotes"
            ItemStyle-HorizontalAlign="Center"
            ItemStyle-CssClass="colNotes">
            <ItemTemplate>
                <asp:Label ID="lblNotes" Runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "note") %>'></asp:Label>
                <%--<asp:HyperLink ID="lnkNotes" Visible='<%# DataBinder.Eval(Container.DataItem, "has_note") %>' Runat="server" Text="..." /> --%>
                <asp:Image ID="lnkNotes" runat="server" Visible='<%# DataBinder.Eval(Container.DataItem, "has_note") %>' ImageUrl="http://www.ezzylearning.com/tutorials/demos/images/magnify.gif" /> 
                <ajax:PopupControlExtender ID="PopupControlExtender1" runat="server"
                    PopupControlID="pnlPopupNotes" 
                    TargetControlID="lnkNotes" 
                    DynamicContextKey='<%# Eval("person_id") +","+Eval("group_id") %>'
                    DynamicControlID="pnlPopupNotes" 
                    DynamicServiceMethod="GetDynamicContent" Position="Bottom"> 
                </ajax:PopupControlExtender> 
            </ItemTemplate>
            </asp:TemplateColumn>

Here is the code for the DynamicServiceMethod (I have intentionally stripped it down to a simple span to just try to get something to display)...

[System.Web.Services.WebMethodAttribute(),
    System.Web.Script.Services.ScriptMethodAttribute()]
    public static string GetDynamicContent(string contextKey) 
    {


       StringBuilder b = new StringBuilder(); 

       b.Append("<span>Hello!</span>");


       return b.ToString(); 
    }

And here is the panel I am using as the PopupControlID...

<asp:Panel ID="pnlPopupNotes" runat="server">

So, with this setup I successfully get the mouseover/mousout behavior, but where I would expect to see a popup of the span, I see a "Web Service call failed: 500" message instead. Any ideas of what I might be missing?

EDIT:

I have discovered that the problem is in how the web service is being called from the page. The web service is actual built within a user control on the same page. When I mouse over, and the web service call is made, I see the URL it is creating to try to access the web server is http://mydomain/default.aspx/GetDynamicContent where it should be something more like http://mydomain/default.aspx/Usercontrols/parentUserControl.ascx/GetDynamicContent However, I cannot figure out how to modify the URL it is calling. I tried changing the DynamicServiceMethod property value from "GetDynamicContent" to http://mydomain/default.aspx/UserControls/parentUserControl.ascx/GetDynamicContent, but that just gave a jumbled mess.

I'm hoping this edit might give more insight to someone who could help me.


Solution

  • I think I figured this one out on my own. Using the debugging console, I was able to see that the mouseover was issuing a webservice call to the main page (whose code I cannot manipulate) and calling the web service method. I had actually created the webservice within a user control (.ascx) that the page was using. This didn't appear to work. I ended up stripping the web service out completely, and creating its own .asmx file, then added the DynamicServicePath attribute to point to the standalone web service. I was hoping I would have to resort to a completely separate web service, but in any case, it works.