HoverMenuExtender - Web Service call failed: 500 (with ASP.NET AJAX 1.0)

Last post 03-07-2007 4:10 AM by oudoulj. 3 replies.

Sort Posts:

  • HoverMenuExtender - Web Service call failed: 500 (with ASP.NET AJAX 1.0)

    01-25-2007, 9:05 AM
    • Loading...
    • oudoulj
    • Joined on 05-30-2006, 11:37 AM
    • France
    • Posts 28

    Hi all,

    I have installed ASP.NET AJAX 1.0 (the 01/23/2007 release)
    I have a usercontrol with a Panel then a Repeater surrounded by an UpdatePanel.

    <asp:Panel ID="panelApres1" runat="server" style="display:none;">
      <p><span style="color:Red;font-size:xx-large">This popup popped at <asp:Label ID="labelApres2" runat="server" /> and all was well.</span></p>
      <p><asp:Button ID="Button1" runat="server" Text="OK" /></p>
    </asp:Panel>

    <asp:UpdatePanel ID="up1" runat="server">
        <ContentTemplate>
            <asp:repeater id="RL" runat="server" EnableViewState="true">
            <ItemTemplate>
                    <tr id="trElement" runat="server">
                      <td id="tdPictoType" runat="server" align="center"></td>
                    </tr>
            </ItemTemplate>
            </asp:repeater>
        </ContentTemplate>
    </asp:UpdatePanel>

    In the ItemDataBound, I dynamically (= in code-behind) add a HoverMenuExtender to each item of the repeater.

    private void RL_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
            {

              HoverMenuExtender hme4 = new HoverMenuExtender();
              hme4.TargetControlID = ((HtmlTableCell)e.Item.FindControl("tdPictoType")).UniqueID;
              hme4.PopupControlID = panelApres1.ID;
              hme4.DynamicControlID = labelApres2.ID;
              hme4.DynamicContextKey = IndTmp.Nom;
              hme4.DynamicServiceMethod = "GetContent";
              hme4.PopupPosition = HoverMenuPopupPosition.Right;
              up1.ContentTemplateContainer.Controls.Add(hme4);

    As you can see, HoverMenuExtender tries to populate the label labelApres2 in my panel panelApres1 with a web service GetContent included in the code-behind as follows :

    [System.Web.Services.WebMethod()]
    public static string GetContent(string contextKey)
    {
          string sIndName = contextKey;
          return "<span style='color:blue;font-size:14pt'>" + sIndName + " " + DateTime.Now + "</span> ";
    }

    Note : I also have added [System.Web.Script.Services.ScriptService] before my class where all my code behind resides.

    [System.Web.Script.Services.ScriptService]
        public abstract class WUCAnnuaireResultat : WUCCcinetDefault
        { ...}

    Unfortunately, when I mouseover the tdPictoType cell, all is displayed is  "This popup popped at Web Service call failed: 500 and all was well."

    Note : on the same page/usercontrol, my tests with HoverMenuExtender without a webservice/dynamic attributes do work. 

    My questions are :

    1 - did I miss an important section in the Web.config in order for web services to work ?

    2 - is my syntax of my webservice and its call correct ? (ie the [System.Web.Script.Services.ScriptService] and [System.Web.Services.WebMethod()]) 

    I used the slightly outdated site

    dynamic-content-made-easy-redux-how-to-use-the-new-dynamic-population-support-for-toolkit-controls

    Thank you for your help !


    Jerome
  • Re: HoverMenuExtender - Web Service call failed: 500 (with ASP.NET AJAX 1.0)

    01-25-2007, 12:44 PM
    Answer
    • Loading...
    • oudoulj
    • Joined on 05-30-2006, 11:37 AM
    • France
    • Posts 28

    Let me reply to myself :

    I've just fount out that I needed to place the webmethod (the following code snippet) in the page itself, NOT in the usercontrol !

    <script runat="server">
    [System.Web.Script.Services.ScriptMethod]
    [System.Web.Services.WebMethod()]
    public static string GetContent(string contextKey)
    {
      string sIndName = contextKey;
      return "<span style='color:blue;font-size:14pt'>" + sIndName + " " + DateTime.Now + "</span> ";
    }
    </script>


    Jerome
  • Re: HoverMenuExtender - Web Service call failed: 500 (with ASP.NET AJAX 1.0)

    03-06-2007, 8:20 PM
    • Loading...
    • andrecarrilho
    • Joined on 02-06-2006, 7:08 AM
    • Lisboa - Portugal
    • Posts 222

    Hi oudoulj

    I followed my problem to this post and solved it. What I was wondering is how come I have to place this code snippet in my aspx page and not in the usercontrol? I'm asking this because I have to return the dynamic data based on some ViewState properties in my UserControl!

    Thx in advance

    André da Silva Carrilho
    http://andrecarrilho.blogspot.com/
    http://dotnetslackers.com/community/blogs/andrecarrilho/

    If the post has been answered please marke it as Answered :-)
    Filed under:
  • Re: HoverMenuExtender - Web Service call failed: 500 (with ASP.NET AJAX 1.0)

    03-07-2007, 4:10 AM
    • Loading...
    • oudoulj
    • Joined on 05-30-2006, 11:37 AM
    • France
    • Posts 28

    I'm afraid I cannot answer your question but since my last post here I switched to a ModalPopupExtender (instead of a HoverMenuExtender).

    In my usercontrol code-behind, I dynamically build a ModalPopupExtender for each item of my repeater :

     
    1    private void RL_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
    2 {
    3 //... 4 ModalPopupExtender mpe1 = new ModalPopupExtender();
    5 mpe1.TargetControlID = ((Label)e.Item.FindControl("Nom_Prenom")).UniqueID; ;
    6 mpe1.PopupControlID = pTest.ID;
    7 mpe1.BackgroundCssClass = "background";
    8 mpe1.DynamicControlID = label2.ID;
    9 mpe1.DynamicContextKey = IndTmp.ID.ToString();
    10 mpe1.DynamicServiceMethod = "GetFiche"; 11 mpe1.DynamicServicePath = "http://localhost/annuaire/rech_coord/wsFicheIndividuelle.asmx"; 12 mpe1.OkControlID = bCloseModal1.ID;
    13 mpe1.CancelControlID = bCloseModal2.ID;
    14 mpe1.PopupDragHandleControlID = pTitreFiche.ID;
    15 16 up1.ContentTemplateContainer.Controls.Add(mpe1);
    17 //... 18 }

    where up1 is an UpdatePanel surrounding my repeater in design view.
    As you can see, I'm able to call a web method in a web service (the web service can even be on remote machine as long as the path is correct I guess)

    Hope this helps if you try to do something similar with your HoverMenuExtender. 


    Jerome
Page 1 of 1 (4 items)
Microsoft Communities
Page view counter