Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUnable to call callControlMethod when there are 2 modulesUnable to call callControlMethod when there are 2 modules
Previous
 
Next
New Post
11/22/2009 3:09 PM
 

Hi,

I am developing some modules with ClientAPI and encountered that when I have 2 modules with ControlMethod callbacks on a single page it doesn't work. There is no problem with the modules when used individually, anyone have any idea? the below are my code snippts:

///////////////// Module 1 - ViewMapClient.ascx.cs /////////////////////

    [ControlMethodClass("MapLingo.MapClient")]
    partial class ViewMapClient : PortalModuleBase, IActionable
    {

       protected void Page_Init(object sender, System.EventArgs e)
        {
            ClientAPI.HandleClientAPICallbackEvent(this.Page);
            ClientAPI.RegisterControlMethods(this, this.ID);
        }

        [ControlMethod()]
        public string Validate(string address)
        {

             //do some stuff

             return "somestring";

        }
    }

///////////////// Module 1 - ViewMapClient.ascx/////////////////////

<%@ Control Language="C#" Inherits="MapLingo.MapClient.ViewMapClient"
    AutoEventWireup="true" CodeBehind="ViewMapClient.ascx.cs" %>
   
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
    TagPrefix="asp" %>   


     <script type="text/javascript">
         function validate() {
             dnn.xmlhttp.callControlMethod('MapLingo.MapClient.ViewMapClient', 'Validate', { address: 'Somestring' }, validateResultSuccess, validateResultFail);
        }

        function validateResultFail(payload, ctx, req) {
            error: ' + payload);
        }

        function validateResultSuccess(payload, ctx, req) {
            oken: ' + payload);
        }
    </script>

<a href="#" onclick="validate()">test</a>

 

///////////////// Module 2 - ViewMapSearch.ascx.cs /////////////////////

    [ControlMethodClass("MapLingo.MapMapSearchResult")]
    partial class MapMapSearchResult: PortalModuleBase, IActionable
    {

       protected void Page_Init(object sender, System.EventArgs e)
        {
            ClientAPI.HandleClientAPICallbackEvent(this.Page);
            ClientAPI.RegisterControlMethods(this, this.ID);
        }

       protected void Page_Load(object sender, System.EventArgs e)
        {
            ClientScriptManager script = Page.ClientScript;
            StringBuilder scriptToInject = new StringBuilder();
            scriptToInject.AppendLine("<script type=\"text/javascript\">");
            scriptToInject.AppendLine("function mapSearchResultSuccess(payload, ctx, req) {");
            scriptToInject.AppendLine("var ctx = { ns: '"+this.ClientID+"_' };");
            scriptToInject.AppendLine("$get(ctx.ns + 'divResults').innerHTML = payload;}");
            scriptToInject.AppendLine("</script>");
            script.RegisterStartupScript(this.GetType(), "CallingScript", scriptToInject.ToString());
        }

        [ControlMethod()]
        public string Search(string address)
        {

             //do some stuff

             return "somestring";

        }
    }

///////////////// Module 2 - ViewMapSearch.ascx /////////////////////

<%@ Control Language="C#" Inherits="Maplingo.MapSearchResult.ViewMapSearchResult"
    AutoEventWireup="true" CodeBehind="ViewMapSearchResult.ascx.cs" %>

<script type="text/javascript">
    function mapSearchResultFail(payload, ctx, req) {
        error: ' + payload);
    }

    function mapSearchResultUpdate()
    {
        dnn.xmlhttp.callControlMethod('MapLingo.MapSearchResult.ViewMapSearchResult', 'Search', { address: 'SomeString' }, mapSearchResultSuccess, mapSearchResultFail);
    }
</script>
<div id="divResults" runat="server">
</div>

 
New Post
11/24/2009 9:34 AM
 

Are you referring to to of the same module or two different modules?  If two of the same, I am concerned as your script is not scoped per module.  I would suggest looking at my free templates on http://codeendeavortemplate.codeplex.com to see how to properly scope your modules.

 


 
New Post
11/25/2009 12:03 PM
 

Thanks for taking the time to reply. I am reffering to 2 different modules on a same page (i have posted the code snippets in my previous post). I have seen your templates and much of the codes I created are referenced from your templates.

 
New Post
12/15/2009 6:27 AM
 

Found the problem. Because I used ClientAPI.HandleClientAPICallbackEvent(this.Page) in Page_Init, removing this solved the problem, but I do not understand why.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIUnable to call callControlMethod when there are 2 modulesUnable to call callControlMethod when there are 2 modules


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out