Products

Solutions

Resources

Partners

Community

About

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 ForumsClientAPIClientAPIConversion from type string to integer errorConversion from type string to integer error
Previous
 
Next
New Post
4/5/2009 9:39 PM
 

I have been researching the ClientAPI and am seriously considering implementing it as a standard feature of all of my future projects. There's only one problem... I can't get it to work. I know I've got to be overlooking something really simple here.

The test project is a simple module.

Here is the ascx code: 

<%@ Control language="vb" Inherits="Modules.APIClientTest.View" CodeFile="View.ascx.vb" AutoEventWireup="false" Explicit="True" %>

<script type="text/javascript">
    function successFunc(result, ctx)
    {
    received: ' + result + ' (' + ctx.id + ')');
    }
   
    function errorFunc(result, ctx)
    {
    failed: ' + result + ' (' + ctx.id + ')');
    }
</script>

<asp:Button ID="mybutton" runat="server" Text="Button" />

 

 

And the vb code behind is:

Imports DotNetNuke
Imports System.Web.UI
Imports DotNetNuke.UI.Utilities

Namespace Modules.APIClientTest

        Partial Class View
        Inherits Entities.Modules.PortalModuleBase
        Implements IClientAPICallbackEventHandler

#Region "Event Handlers"

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                    If ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XMLHTTP) _
                    AndAlso ClientAPI.BrowserSupportsFunctionality(ClientAPI.ClientFunctionality.XML) Then
                        ClientAPI.RegisterClientReference(Me.Page, ClientAPI.ClientNamespaceReferences.dnn_xml)
                        ClientAPI.RegisterClientReference(Me.Page, ClientAPI.ClientNamespaceReferences.dnn_xmlhttp)
                    End If

                    mybutton.Attributes.Add("onclick", ClientAPI.GetCallbackEventReference(Page, "'test'", "successFunc", "this", "errorFunc"))
    

            Catch exc As Exception
                ProcessModuleLoadException(Me, exc)
            End Try
        End Sub

#End Region

        Public Function RaiseClientAPICallbackEvent(ByVal EVENT_ARGUMENT As String) As String Implements DotNetNuke.UI.Utilities.IClientAPICallbackEventHandler.RaiseClientAPICallbackEvent
            Return "HELLO: " & EVENT_ARGUMENT
        End Function
    End Class

End Namespace
 

 When I run this module on a page I always get the same result. - errFunc is triggered and the 'result' variable contains:

400 - Conversion from string "test" to type 'Integer' is not valid.

Firebug indicates that a successful post has occured and I see the two variables populated correctly in the post data. It appears that there is indeed a round trip happening and the invalid conversion is happening at the server. Any idea what could cause this or what I could do to trace it further?

 

 
New Post
4/6/2009 8:55 AM
 

I have a sample module you can compare here (I believe the forum editor stripped out portions of your code).  Also, you may like to investigate my new templates for you project (http://codeendeavortemplate.codeplex.com), which includes video tutorials.


 
New Post
4/6/2009 1:15 PM
 

Actually, I figured it out this morning. Here is what I found:

I was using the Client API Callback pdf as a guide, which demonstrates triggering the process from a button as follows:

mybutton.attributes.add("onclick", GetCallbackEventReference(Page, "'test'", "successFunc", "this", "errorFunc")

This would cause the error every time. I made the following change and everything worked fine:

mybutton.attributes.add("onclick", GetCallbackEventReference(Me, "'test'", "successFunc", "this", "errorFunc")

Notice the only change is in the 1st param of the GetCallbackEventReference method. Since I am working at the module level, Me is the appropriate reference, not the page that the module exists on. I knew it had to be something obvious and minor.

All works great now! Awsome work on the ClientAPI and thank you. This API is miles ahead of anything else out there and your documentation is a real jewel. I have learned more about AJAX, Client-side scripting and RPC in two days of reading your articles than I have with everything else I have found over the past 6 months or more.

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsClientAPIClientAPIConversion from type string to integer errorConversion from type string to integer error


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