I am currently developing a module for DotNetNuke 4.3.5, and trying to use the Client API. I have duplicated the HelloAjax ascx and javascript file as in the example. I am getting a fast array of spurious errors, dependand on how much I duplicate the code. If I remove the the lines;
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
I get the Cast Error others have reported, when included 404 Control Not Found error. But when logged in as a subscriber, portal admin or host it all works fine.
Here is the ascx file
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="SearchHBJobs.ascx.vb" Inherits="HiBrowWeb.Modules.HBJobs.SearchHBJobs" %> <asp:label id="Label1" runat="server">Enter Text</asp:label><br> <asp:textbox id="TextBox1" runat="server"></asp:textbox><br> <INPUT id="Button1" type="button" value="Invoke AJAX Method" name="Button1" runat="server"> <INPUT id="chkContinuous" type="checkbox" name="chkContinuous" runat="server"> Continuous <BR>
Here is the vb file
Imports DotNetNuke Imports DotNetNuke.UI.Utilities
Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls
Namespace HiBrowWeb.Modules.HBJobs Partial Class SearchHBJobs Inherits Entities.Modules.PortalModuleBase Implements Entities.Modules.IActionable Implements IClientAPICallbackEventHandler #Region "Private Members" #End Region #Region "Event Handlers" Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load ''these won't be necessary in next release after 3.2.0 '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)
'Only this line will be necessary after 3.2 Me.Button1.Attributes.Add("onclick", ClientAPI.GetCallbackEventReference(Me, "dnn.dom.getById('" & Me.TextBox1.ClientID & "').value", "successFunc", "'" & Me.ClientID & "'", "errorFunc")) Me.chkContinuous.Attributes.Add("onclick", "toggleCont('" & Me.ClientID & "')")
If Me.Page.ClientScript.IsClientScriptBlockRegistered("helloajax.js") = False Then Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "helloajax.js", "<script language=javascript src=""" & Me.ModulePath & "helloajax.js""></script>") End If
'End If
End Sub #End Region #Region "Optional Interfaces" ''' ----------------------------------------------------------------------------- ''' <summary> ''' Registers the module actions required for interfacing with the portal framework ''' </summary> ''' <value></value> ''' <returns></returns> ''' <remarks></remarks> ''' <history> ''' </history> ''' ----------------------------------------------------------------------------- Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions Get Dim Actions As New Entities.Modules.Actions.ModuleActionCollection Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False) Return Actions End Get End Property
Protected Function RaiseClientAPICallbackEvent(ByVal EventArgs As String) As String _ Implements IClientAPICallbackEventHandler.RaiseClientAPICallbackEvent Return "Hello: " & EventArgs End Function #End Region End Class End Namespace
And JS file
function successFunc(result, ctx) { if (dnn.dom.getById(ctx + '_chkContinuous').checked) { dnn.dom.getById(ctx + '_Label1').innerHTML = result; dnn.doDelay(ctx, 1000, doCont, ctx); } else alert('result: ' + result + '\ncontext:' + ctx); }
function doCont(ns) { dnn.dom.getById(ns + '_Button1').onclick(); }
function errorFunc(result, ctx) { alert(result); }
function toggleCont(ns) { if (dnn.dom.getById(ns + '_chkContinuous').checked) doCont(ns); }
The most curiouse thing is, as is the HelloAjax module works absolutly fine. Also just a bit of background the module was originally generated by the DotNetNuke Starter Kit.
Additionally I have tested another suggestion on this forum, of diabling the caching for the module. This did not solve my issue.
Thanks to anyone that can help.
|