vb.netlistviewautopostbackwinforms-to-weblostfocus

ASP.NET VB.NET - Winforms to Web - implementing LostFocus listview control equivalent for web


Background: I have a winForm app that registers a user in the database based on the information provided, auto-generates a random password and username, and e-mails the user a link to take an application based on the marketing company selected.

Problem:

web app screenshot

Code from default.aspx.vb:

Private Sub lbCarriers_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles lbCarriers.LostFocus
    Dim splt() As String
    Dim ac1 As Array
    bundles.Items.Clear()
    For Each item In lbCarriers.Items

        splt = Split(item.text, "|")
        ac1 = proxy.GetContractingBundles("test", "test", Trim(splt(0)))
        For Each Pitem In ac1
            bundles.Items.Add(Trim(splt(2)) & " | " & Pitem.FormBundleName)
        Next
    Next
End Sub

Protected Sub lbCarriers_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles lbCarriers.SelectedIndexChanged

End Sub

Solution

  • You'll need to do some client-side javascript, or add an AutoPostBack on the dropdownlist and code the OnSelectedIndexChanged event:

    <asp:DropDownList AutoPostBack="true" OnSelectedIndexChanged="MethodName" ...
    

    Also, the LostFocus event only fires on the client, not on the server, and it is a Javascript event called "Blur":

    http://www.java2s.com/Code/JavaScriptReference/Javascript-Methods/blur.htm