Asp.net Ajax ModalPopupExtender DynamicMethod Never been Called

YesOrKnow
YesOrKnow used Ask the Experts™
on
Hi every expert,

My task is to add a ModalPopupExtender onto my asp.net page APage.aspx, and list a table of records with CheckBoxes and contents in the popup dialog. Users are able to select some interest rows, and after they click OK button, the selected data id values should be return back to its original page APage.aspx.

I have read the article from http://www.codeproject.com/KB/ajax/Dynamic_AJAX_Modal_Popup.aspx

Then I tried the following:

1. Register Ajax assembly in my APage.aspx:
 
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>

Open in new window


2. Add a button "btnSelectRows", and a panel "pnlRows"
 
<asp:Button ID="btnSelectRows" Text="Select Rows" runat="server" onclick="btnSelectRows_Click" />

<asp:Panel ID="pnlRows" runat="server" style="display:block;width:auto;" BackColor="White">
    <div>
         <asp:Panel id="pnlHeader" runat="server">
             <p><h3><b>Please Choose the rows you would like to use:</b></h3></p>
         </asp:Panel>
    </div>
    <div>
         <table id="tblPopup">
              <thead class="popupheading">
                  <tr>
                      <th style="width: auto; background: #6E9ECA; font-size: 10pt; color: white"><b>Selected</b></th>
                      <th style="width: auto; background: #6E9ECA; font-size: 10pt; color: white"><b>Note Type</b></th>
                      <th style="width: auto; background: #6E9ECA; font-size: 10pt; color: white"><b>Common Note</b></th>
                  </tr>
              </thead>
              <tbody>
                  <asp:Label ID="lblCommonNotes" runat="server"></asp:Label>
                  <tr>
                    <td></td>
                    <td></td>
                    <td class="popupfooter">
                         <asp:Button ID="btnOK" runat="server" Text="OK" />
                         <asp:Button ID="btnCancel" runat="server" Text="Cancel" />
                    </td>
                  </tr>
              </tbody>
         </table>
    </div>
</asp:Panel>

Open in new window


3. Add ModalPopupExtender:
 
<ajaxToolkit:ModalPopupExtender ID="mpeSelectRows" runat="server"
        TargetControlID="btnOK"
        PopupControlID="pnlSelectRows"
        BackgroundCssClass="modal" 
        DynamicServicePath="../RowsService.asmx"
        DynamicServiceMethod="GetRows"
        DynamicControlID="lblRows"
        DropShadow="true" 
        OkControlID="btnOK" 
        CancelControlID="btnCancel" 
        PopupDragHandleControlID="pnlHeader" />

Open in new window


4. Add a web service methods:
 
[System.Web.Script.Services.ScriptService]
.....
    [WebMethod]
    public string GetRows(string contextKey)
    {
        StringBuilder _sb = new System.Text.StringBuilder();

        RowList rows = new RowList();
        rows.Load(contentKey);
        foreach(Row r in RowList)
        {
          _sb.Append("<tr>");
          _sb.Append("    <td align=\"right\">" + r.A + "</td>");
          _sb.Append("    <td align=\"center\">" + r.B + "</td>");
          _sb.Append("    <td align=\"center\">" + r.C + "</td>");
          _sb.Append("</tr>");
        }

        return _sb.ToString();
    }

Open in new window


5. In order to pass in the contextKey value, I added a click button event handler for the btnSelectRows called btnSelectRows_Click:
 
protected void btnSelectRows_Click(object sender, EventArgs e)
    {
        if (ViewState["Parent Record"] != null)
        {
            mpeSelectRows.DynamicContextKey = (RowType)ViewState["Parent Record"].Id.ToString();
            mpeSelectRows.Show();
        }
    }

Open in new window


After I run the project, I found the web method GetRows is never called, and I am not sure what's my problem.

Please help.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Where do u call it

Author

Commented:
First of all, a correction of my code in step 3:

<?xml:namespace prefix = ajaxToolkit />        TargetControlID="btnSelectRows"
         ................
6. In my APage.aspx file, I added btnSelectRows button :
             <asp:Button id="btnSelectRows" runat="server" onClick="btnSelectRows_Click" Text="Select Rows" />
After the user click this button, the modal mpeSelectRows will popup.

Author

Commented:
First of all, a correction of my code in step 3: TargetControlID is the select rows button.

<ajaxToolkit:ModalPopupExtender id=mpeSelectRows
        TargetControlID="btnSelectRows"
        ................</ajaxToolkit:ModalPopupExtender>

6. In my APage.aspx file, I added btnSelectRows button :</ajaxToolkit:ModalPopupExtender>

         <asp:Button id="btnSelectRows" runat="server" onClick="btnSelectRows_Click" Text="Select Rows" />

After the user click this button, the modal mpeSelectRows will popup.
Problem solved, DynamicServicePath is not specified properly.
Thanks for reading the thread.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial