Hi Pat,
Your thread above gave me an idea to communicate from client in a DNN module, I tried to call a webservice webmethod using client side script and I get javascript error like namespace is not defined. I assume the script manager is not generating the proxy class on the client side. Could you please look at my code and point out what is wrong.
.ASCX
<%@ Control Language="vb" AutoEventWireup="false" CodeBehind="ImageViewer.ascx.vb" Inherits="Accretive.Controls.Tasks.Remittance.ImageViewer" %>
<%@ Register assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" namespace="System.Web.UI" tagprefix="asp" %>
<br /><br /><br />
Enter name : <input type="text" id="txtName" />
<br /><br /><br />
<input type="button" id="btnSave" value="Click Me" onclick="Getmyname()" />
.VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim objScriptManager As ScriptManager
Dim objServiceReference As ServiceReference
If DotNetNuke.Framework.AJAX.IsInstalled Then
objScriptManager = ScriptManager.GetCurrent(Me.Page)
objServiceReference = New ServiceReference
objServiceReference.Path = ResolveUrl("LockBoxImage.asmx")
objScriptManager.Services.Add(objServiceReference)
End If
Dim cscrpt As String = "function Getmyname()" & _
"{" & _
" var name = $get(""txtName"").value;" & _
" Accretive.Controls.Tasks.Remittance.LockBoxImage.Getmyname(name, OnSuccess, OnFailed);" & _
"}" & _
"function OnSuccess(Result) {" & _
" Result);" & _
"}" & _
"function OnFailed(error) {" & _
" error.get_message());" & _
"}" & _
"function Popmsg() {" & _
" it works now!');" & _
"}"
ScriptManager.RegisterClientScriptBlock(Me.Page, Page.GetType(), "wsspt", cscrpt, True)
End Sub
.ASMX
Imports System.Web.Services
Namespace Accretive.Controls.Tasks.Remittance
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
<System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class LockBoxImage
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function Getmyname(ByVal Nme As String) As String
Return Nme & " you click at " & Date.Now.ToString
End Function
End Class
End Namespace
FYI, the webservice it located on the same folder and support partial rendering is enabled for this module. When I click the button I get a javascript error as below.
Error: 'Accretive' is undefined.
Your help will be highly appreciated!
Thanks,
Vinoth