Hi,
I am trying to use AutoCompleteExtender to make a search as you type search feature in one of my modules. I have been reading a bunch of sites in trying to get this to work (also downloaded a cheap module from snowcovered to try to get it working) If I take out my script manager everything shows up on the page correctly, but the search as you type does not show up at all. It is just like typing in a text box. If I add in the ScriptManager I get the following error:
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
ExceptionGUID: 49604bc8-ce86-45c9-bf23-ef7687655715
InnerException: Object reference not set to an instance of an object.
FileName:
FileLineNumber: 0
FileColumnNumber: 0
Method: DotNetNuke.UI.Containers.ActionButtonList.get_ModuleActions
StackTrace:
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.UI.Containers.ActionButtonList.get_ModuleActions() at DotNetNuke.UI.Containers.ActionButtonList.OnLoad(EventArgs e) at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Control.LoadRecursive() at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---
I am trying to make everything as simple as I possibly can but I cant seem to get it to work. Here is a list of my ascx page, ascx.vb page and my webservice AutoComplete.asmx. I have tried doing this enabling and disabling Partial Rendering under the module control but it did not work
Thanks for any help.
Chris
.ascx page
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="ContactToPolicy.ascx.vb" Inherits="ACSI.Modules.ClaimsAssociation.ContactToPolicy" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods = "true">
</asp:ScriptManager>
<asp:TextBox ID="txtContactsSearch" runat="server"></asp:TextBox>
<cc1:AutoCompleteExtender ServiceMethod="SearchCustomers"
MinimumPrefixLength="2"
CompletionInterval="100" EnableCaching="false" CompletionSetCount="10"
TargetControlID="txtContactsSearch"
ID="AutoCompleteExtender1" runat="server" FirstRowSelected = "false" ServicePath="AutoComplete.asmx">
</cc1:AutoCompleteExtender>
ascx.vb page
Imports DotNetNuke
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke.Framework.AJAX
Imports System.Web.UI.ScriptManager
Namespace ACSI.Modules.ClaimsAssociation
Partial Class ContactToPolicy
Inherits Entities.Modules.PortalModuleBase
#Region "Private Members"
Private strTemplate As String
#End Region
#Region "Event Handlers"
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
objServiceReference.Path = "~/DesktopModules/ClaimsAssociation/AutoComplete.asmx"
objScriptManager.Services.Add(objServiceReference)
End If
End Sub
#End Region
End Class
End Namespace
and the webservice AutoComplete.asmx (the vb portion)
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
'Add Namespace references
Imports System.Collections.Generic
Imports Microsoft.ApplicationBlocks.Data
Imports DotNetNuke.Common.Utilities
Imports System.Data
Imports System.Data.SqlClient
Imports AjaxControlToolkit
'Don't forget to add System.Web.Script.Services.ScriptService attribute
<System.Web.Script.Services.ScriptService()> _
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Public Class WebService
Inherits System.Web.Services.WebService
'String List for return
Protected returnStr As New List(Of String)
'Web Method would be called by auto complete extender
<WebMethod()> _
Public Shared Function SearchCustomers(ByVal prefixText As String, ByVal count As Integer) As List(Of String)
Dim ConnectionString As String = "Server=***;Database=***;uid=***;pwd=***;"
Dim Connection As New SqlConnection(ConnectionString)
Connection.Open()
Dim SqlQuery = "select LongName from Contacts where LongName like '%" & prefixText & "%'"
Dim cmd As SqlCommand = New SqlCommand(SqlQuery, Connection)
Dim customers As List(Of String) = New List(Of String)
Dim sdr As SqlDataReader = cmd.ExecuteReader
While sdr.Read
customers.Add(sdr("LongName").ToString)
End While
Return customers
End Function
End Class