tentavarious
asked on
Help with ajax auto suggestion textbox asp.net 1.1
Hello experts, I am trying to create a suggest textbox for a asp.net web page I am developing. I found lots of code but is not in vb.net. My main problem is how do I select only the suggested text in the textbox so that the user can keep typing?
Here is my ajax codebehind function that retrieves the suggestions from the database
<Ajax.JavascriptMethod()> _
Function check_name(ByVal first_name As String) As String
Dim ssql As String
Dim firstname As String
ssql = "Select First_name from tablename where First_Name like '" & first_name.ToUpper & "%'"
Dim dr As OracleDataReader
dr = GetData(ssql)
If dr.HasRows = True Then
While dr.Read
firstname = dr.GetString(0)
End While
End If
Dim int As Integer = first_name.Length
Return firstname.Remove(0, int).ToLower
End Function
here is my aspx page with the javascript
<script language="javascript">
function checkname()
{
document.getElementById('t xtfirstnam e').value += check_name(document.getEle mentById(' txtfirstna me').value )
}
</script>
<a onkeyup="checkname();"><as p:textbox id="txtfirstname" runat="server" BackColor="Cornsilk"></asp :textbox>< /a>
So basically if I have a firstname of steve in the database, and I type "s" in the textbox I would return the "teve", my problem is I need to select only the "teve" text so that the user can keep typing, any ideas?
Here is my ajax codebehind function that retrieves the suggestions from the database
<Ajax.JavascriptMethod()> _
Function check_name(ByVal first_name As String) As String
Dim ssql As String
Dim firstname As String
ssql = "Select First_name from tablename where First_Name like '" & first_name.ToUpper & "%'"
Dim dr As OracleDataReader
dr = GetData(ssql)
If dr.HasRows = True Then
While dr.Read
firstname = dr.GetString(0)
End While
End If
Dim int As Integer = first_name.Length
Return firstname.Remove(0, int).ToLower
End Function
here is my aspx page with the javascript
<script language="javascript">
function checkname()
{
document.getElementById('t
}
</script>
<a onkeyup="checkname();"><as
So basically if I have a firstname of steve in the database, and I type "s" in the textbox I would return the "teve", my problem is I need to select only the "teve" text so that the user can keep typing, any ideas?
why don't you use the autocomplete extender?
ASKER
I have never heard of it, is it a asp.net control? Will it work with asp.net 1.1?
You can get it from the July CTP on the atlas.asp.net site. It's been pulled from the Beta for support reasons (MS are cuttiong back atlas to a supportable size prior to release) but it works fine. I think it will work with 1.1 as it really just javascript talking to a web service.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
What the F*%$. Why did peterdungan get the points?
Type in atlas.asp.net and it is redirected to http://ajax.asp.net anyway. It was my answer that tell you why simply gouing to http://ajax.asp.net is not good enought. You have to get the July CTP.
Type in atlas.asp.net and it is redirected to http://ajax.asp.net anyway. It was my answer that tell you why simply gouing to http://ajax.asp.net is not good enought. You have to get the July CTP.
ASKER
I guess because i will be using the autocomplete extender which was his idea.