Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populating a Textbox from Popup extender.

Status
Not open for further replies.

Dashley

Programmer
Dec 5, 2002
925
US
Im using the popupextender on a form. Its an autocompletion routine that works well.

Client starts typing in the city and a list of cities appears - client then selects from the list and the selected city appears in the targetid textbox "TBAutoCompleteTo" as advertised. I have anouther textbox TBZipTO which I want to populate with the zipcode belonging to the selected city.

Can somone point me in the right direction?

Thanks

-dan

The function is use to populate the array im passing back is like this:
Code:
    <WebMethod()> _
        Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()
        Dim Mycity As String = Nothing
        Dim conn As New MySqlConnection(System.Configuration.ConfigurationManager.AppSettings("connStringmysql"))

        If conn.State = Data.ConnectionState.Closed Then conn.Open()
        Dim cmd As New MySqlCommand
        Dim DR As MySqlDataReader
        With cmd
            .Connection = conn
            .CommandText = ("select city,areacode, zipcoe from zipcodes where City Like '" & prefixText & "%' and state = 'TN'")
        End With

        Try
            DR = cmd.ExecuteReader

        Catch ex As Exception

        End Try

        Dim items As New List(Of String)
        While DR.Read
            Mycity = DR(0)
            items.Add(Mycity & " Area Code " & DR(1).ToString)
        End While

        conn.Close()
        conn.Dispose()

        Return items.ToArray()
    End Function


The extendor look slike this.

<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" TargetControlID="TBAutoCompleteTo" ServicePath="autocomplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="3" CompletionSetCount="12" EnableCaching="true" >
</ajaxToolkit:AutoCompleteExtender>
 
are you sure your sql is correct. there appears to be a misspelling of zipcode that could be causing your code to fail.
 
Yeah It was speleed wrong and I fiexed it.

The code above works fine (after I changed it).

The completion lists populates and when an item is selected it puts the correct entry in the autocomplete textbox.

What I want to do is feed another textbox the zip code.
For the sake of explaination there will be two TB's.

TB1 is the autocomplete. Its works. A list of cities, area codes and zips appears in the autocomplete (TB1) and when the client selects from the list the correct information shows up in the TB1.

I wnat just the ZIP to show up in TB2 after the selection from the autocomplete (TB1) is selected.

Hope this helps.

-dan
 
use the onblur event of the autocomplete control, take its value, parse the value for the postcode and write it to the value of the textarea. this is all plain javascript and not ajax related.
 
jpadie,

Hi.


the AutoCompleteExtender (if thats what you mean by autocomplete control) dosn't show a Onblur event or any attribute like it. Ive also hecked the textbox for the autocomplete and don't see one in the intellisense.



-dan
 
i assume that the autoextender and the textbox both manifest themselves in the DOM as ordinary html form controls. if so then the events exist. if not, then you will need to be more explicit as to what they actually are (perhaps posting the generated source code).
 
I'm doing theis in ASP.net 2.0 using AJAX control extenders.


The AJAX AutoCompleteExtender looks like this.

Code:
<ajaxToolkit:AutoCompleteExtender ID="AutoCompleteExtender2" runat="server" TargetControlID="TBAutoCompleteFrom" ServicePath="autocomplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="3" CompletionSetCount="12" EnableCaching="true" >

</ajaxToolkit:AutoCompleteExtender>

The text box is like this

Code:
<asp:TextBox ID="TBAutoCompleteFrom" runat="server" Height="12px" Width="318px"></asp:TextBox>


There is a extendercontolbase.cs file behind the scenes.

 
and you're saying that this is what the _generated_ html looks like in the browser? i don't think my browser would understand that.
 
from looking at the ajaxtoolkit webpage I see that the generated html of the example page contains this element for the actual text box:

Code:
<input type="text" style="width: 300px;" autocomplete="off" id="ctl00_SampleContent_myTextBox" name="ctl00$SampleContent$myTextBox"/>

i suggest you attach an event listener to this control and onblur submit its contents to your text box.
 
Ok I'll give the event handler a try. I should be able ot get one going.

I'l let you know the outcome

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top