Whap
04-18-2008, 01:39 AM
Hey all,
I need create an autocomplete text box that pulls it's data from a MySql database. The website I'm working on is written in VB.net, and uses the Microsoft Ajax Toolkit. I've found some examples for how to do this using a webservice in C# or C. I've tried converting them to VB.net, but have been unsucessful in getting the textbox to trigger my "getwordlist" function when the text is changed in the texbox. I'm sure I'm just missing something simple here, but 2 days into this I've been unable to find it. Here is my code. Any help would be greatly appreciated!
.aspx code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="editprofile.aspx.vb" Inherits="Site_editprofile" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Edit Profile</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode=Conditional>
<ContentTemplate>
<asp:Panel ID="EducationPanel" runat="server" BackColor="Lavender" Height="504px" Style="z-index: 11;
left: 8px; position: absolute; top: 8px" Width="600px">
<asp:Label ID="Label24" runat="server" Font-Names="Arial" Font-Size="Smaller" Style="z-index: 100;
left: 104px; position: absolute; top: 64px" Text="College/University" Width="112px"></asp:Label>
<asp:Label ID="Label25" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Larger"
Style="z-index: 101; left: 248px; position: absolute; top: 8px" Text="Education"
Width="88px"></asp:Label>
<asp:TextBox ID="tbcollege" runat="server" Style="z-index: 102; left: 224px; position: absolute; top: 64px" Width="272px" OnTextChanged="tbcollege_TextChanged"></asp:TextBox>
<asp:Label ID="Label27" runat="server" Font-Names="Arial" Font-Size="Smaller" Style="z-index: 103;
left: 136px; position: absolute; top: 200px" Text="Hgh School" Width="72px"></asp:Label>
<asp:TextBox ID="tbhighschool" runat="server" AutoPostBack="True" Style="z-index: 104;
left: 224px; position: absolute; top: 192px" Width="272px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="z-index: 107; left: 272px; position: absolute;
top: 456px" Text="Save Changes" Width="120px" TabIndex="17" />
<asp:Label ID="Label36" runat="server" Font-Bold="True" Font-Names="arial" ForeColor="Green"
Style="z-index: 109; left: 416px; position: absolute; top: 464px" Text="Changes Saved"
Visible="False" Width="184px"></asp:Label>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
MinimumPrefixLength="1"
ServiceMethod="GetWordList"
ServicePath="AutoComplete.asmx"
TargetControlID="tbcollege">
</cc1:AutoCompleteExtender>
</contentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</div>
</form>
</body>
</html>
Web service code
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> Public Class AutoComplete
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetWordList(ByVal prefixText As String, ByVal count As Int16) As String()
Dim S(count - 1) As String
Dim I As Integer
For I = 0 To count - 1
S(I) = prefixText & " " & Environment.TickCount
Next
Return S
End Function
End Class
I need create an autocomplete text box that pulls it's data from a MySql database. The website I'm working on is written in VB.net, and uses the Microsoft Ajax Toolkit. I've found some examples for how to do this using a webservice in C# or C. I've tried converting them to VB.net, but have been unsucessful in getting the textbox to trigger my "getwordlist" function when the text is changed in the texbox. I'm sure I'm just missing something simple here, but 2 days into this I've been unable to find it. Here is my code. Any help would be greatly appreciated!
.aspx code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="editprofile.aspx.vb" Inherits="Site_editprofile" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Edit Profile</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode=Conditional>
<ContentTemplate>
<asp:Panel ID="EducationPanel" runat="server" BackColor="Lavender" Height="504px" Style="z-index: 11;
left: 8px; position: absolute; top: 8px" Width="600px">
<asp:Label ID="Label24" runat="server" Font-Names="Arial" Font-Size="Smaller" Style="z-index: 100;
left: 104px; position: absolute; top: 64px" Text="College/University" Width="112px"></asp:Label>
<asp:Label ID="Label25" runat="server" Font-Bold="True" Font-Names="Arial" Font-Size="Larger"
Style="z-index: 101; left: 248px; position: absolute; top: 8px" Text="Education"
Width="88px"></asp:Label>
<asp:TextBox ID="tbcollege" runat="server" Style="z-index: 102; left: 224px; position: absolute; top: 64px" Width="272px" OnTextChanged="tbcollege_TextChanged"></asp:TextBox>
<asp:Label ID="Label27" runat="server" Font-Names="Arial" Font-Size="Smaller" Style="z-index: 103;
left: 136px; position: absolute; top: 200px" Text="Hgh School" Width="72px"></asp:Label>
<asp:TextBox ID="tbhighschool" runat="server" AutoPostBack="True" Style="z-index: 104;
left: 224px; position: absolute; top: 192px" Width="272px"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="z-index: 107; left: 272px; position: absolute;
top: 456px" Text="Save Changes" Width="120px" TabIndex="17" />
<asp:Label ID="Label36" runat="server" Font-Bold="True" Font-Names="arial" ForeColor="Green"
Style="z-index: 109; left: 416px; position: absolute; top: 464px" Text="Changes Saved"
Visible="False" Width="184px"></asp:Label>
<cc1:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server"
MinimumPrefixLength="1"
ServiceMethod="GetWordList"
ServicePath="AutoComplete.asmx"
TargetControlID="tbcollege">
</cc1:AutoCompleteExtender>
</contentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</div>
</form>
</body>
</html>
Web service code
Imports System.Web
Imports System.Web.Services
Imports System.Web.Services.Protocols
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> Public Class AutoComplete
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function GetWordList(ByVal prefixText As String, ByVal count As Int16) As String()
Dim S(count - 1) As String
Dim I As Integer
For I = 0 To count - 1
S(I) = prefixText & " " & Environment.TickCount
Next
Return S
End Function
End Class