'
' DotNetNuke - http:'www.dotnetnuke.com
' Copyright (c) 2002-2005
' by Perpetual Motion Interactive Systems Inc. ( http:'www.perpetualmotion.ca )
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
'
 
Imports DotNetNuke
Imports DotNetNuke.Security.Roles
Imports System.Collections.Generic
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System
Imports DotNetNuke.Services.Localization
Imports DotNetNuke.Security
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Security.PortalSecurity
Imports System.Web
 
Namespace DotNetNuke.Modules
    Public Class AJAXIWebSample
        Inherits DotNetNuke.Entities.Modules.PortalModuleBase
 
        Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 
            ' Determine if AJAX is installed
            If DotNetNuke.Framework.AJAX.IsInstalled Then
		  DotNetNuke.Framework.AJAX.RegisterScriptManager()
                ' Create a reference to the Script Manager
                Dim objScriptManager As ScriptManager = ScriptManager.GetCurrent(Me.Page)
                ' Add a reference to the web service
                Dim objServiceReference As ServiceReference = New ServiceReference
                ' Here we are pointing to the IWEB web service entry point
                ' IWEB must be installed for this to work
                objServiceReference.Path = "~/DesktopModules/IWeb/WebService.asmx"
                objScriptManager.Services.Add(objServiceReference)
                Dim objScriptReference As ScriptReference = New ScriptReference
                ' Here we are pointing to the file that contains the JavaScript method that will call the method
                ' in the IWEB web service
                objScriptReference.Path = "~/DesktopModules/AjaxIWebSample/CallWebServiceMethods.js"
                objScriptManager.Scripts.Add(objScriptReference)
 
                Dim objUser As Entities.Users.UserInfo
                objUser = Entities.Users.UserController.GetCurrentUserInfo
 
                If objUser.UserID > -1 Then
                    Dim intPortalID As Integer = objUser.PortalID
                    Dim strUsername As String = objUser.Username.ToString()
                    Dim intUserID As Integer = objUser.UserID
                    Dim strPassword As String = ""
                    strPassword = DotNetNuke.Modules.IWeb.IWebAJAXSupport.SetAJAXCall(objUser, ModuleId)
                    Me.btnGetUserInfo.Attributes.Add("onClick", String.Format("GetUser({0},{1},'{2}','{3}','{4}',{5},{6});", intPortalID, intUserID, strUsername, strPassword, ModuleId.ToString, "true", "false") & "; return false;")
                End If
            End If
 
        End Sub
 
    End Class
 
End Namespace