Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Autocomplete Text box doesn't show suggestions

Author  Topic 

bubberz
Constraint Violating Yak Guru

289 Posts

Posted - 2006-07-25 : 08:42:50
Hello! I've posted this on other sites, and was given the tip to try ASP.NET forums.

This is my first try at this control, http://www.autosuggestbox.com/Downloads/Download.aspx.

I can type in the text box w/o any error, but don't see any suggestions
and there's a little blue box that appears under the text box while I'm
typing. So, it looks like it's trying, but I've got something wrong. I can look (response.Write()) the SQL, and it's correct for bringing back suggestions.


The main page I'm trying to use is WebForm1, which holds the text box you type in:


<%@ Register TagPrefix="Custom" Namespace="ASB"
Assembly="AutoSuggestBox" %>
<%@ Page Language="vb" AutoEventWireup="false"
Codebehind="WebForm1.aspx.vb"
Inherits="AutoCompleteTextBox1.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<DIV style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px"
ms_positioning="text2D">
<Custom:AutoSuggestBox id="asbAuth" DataType="Authority"
runat="server"
CssClass="FormCtrlStyle" MaxLength="100" Columns="30"
ResourcesDir="/AutoCompleteTextBox1/asb_includes" />
</DIV>
</form>
</body>
</HTML>


The code behind is empty for this page, WebForm1.aspx.vb.


I did try to edit the GetAutoSuggestData.aspx.vb page such as to only
pull the "Authority" field from my table, Signature_Authority_Names.
This is a field which shows the last and first name of users.

Here's a simplified version of my code behind for GetAutoSuggestData.vb.aspx.
I can response.Write my SQL, and it's right. Seems the LoadCities() is my problem area.....I think.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load


'Turn off cache
Response.Cache.SetCacheability(HttpCacheability.NoCache)


msTextBoxID = Request.QueryString("TextBoxID")
msMenuDivID = Request.QueryString("MenuDivID")
msDataType = Request.QueryString("DataType")
mnNumMenuItems =
Convert.ToInt32(Request.QueryString("NumMenuItems"))
mbIncludeMoreMenuItem =
Convert.ToBoolean(Request.QueryString("IncludeMoreMenuItem"))
msMoreMenuItemLabel = Request.QueryString("MoreMenuItemLabel")
msMenuItemCSSClass = Request.QueryString("MenuItemCSSClass")
msKeyword = Request.QueryString("Keyword")


'Get menu item labels and values
Dim aMenuItems As ArrayList = LoadMenuItems()


'Generate html and write it to the page
Dim sHtml As String
sHtml = AutoSuggestBox.GenMenuItemsHtml(aMenuItems, _
msTextBoxID, _
mnNumMenuItems, _
mbIncludeMoreMenuItem,
_
msMoreMenuItemLabel, _
msMenuItemCSSClass)
Response.Write(sHtml)


End Sub


Private Function LoadCities(ByVal sKeyword As String) As ArrayList
Dim aOut As ArrayList = New ArrayList


Dim sSql As String
Dim strKeyR As String = sKeyword.Replace("'", "''")
sSql = "Select Authority FROM Signature_Authority_Names WHERE
Authority Like '" & strKeyR & "%'"
Dim oCmd As SqlCommand = New SqlCommand(sSql, sCon1)
sCon1.Open()


Dim oReader As SqlDataReader = oCmd.ExecuteReader()
Dim sAuth As String
Dim sLabel As String
Dim oMenuItem As ASBMenuItem


While oReader.Read()


sLabel = sAuth


oMenuItem = New ASBMenuItem
oMenuItem.Label = sLabel
oMenuItem.Value = sAuth


aOut.Add(oMenuItem)


End While


oReader.Close()
sCon1.Close()


Return aOut
End Function


Function LoadMenuItems() As ArrayList
Dim aMenuItems As ArrayList


Select Case (msDataType)
Case "Authority"
aMenuItems = LoadCities(msKeyword)
Case Else
Throw New Exception("GetAutoSuggestData Type '" &
msDataType & "' is not supported.")
End Select


LoadMenuItems = aMenuItems


End Function

*********************************
*********************************

Thanks for any help or suggestions!
   

- Advertisement -