Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Editing a text box
Message
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Titre:
Editing a text box
Divers
Thread ID:
00921475
Message ID:
00921475
Vues:
65
ASP NET Edit a Text Box using VB.NET

As my skills with ASP.NET increase I look for first the simple and later the elegant way to accomplish a task.

My interest was to fire a value from a data drop down list box, populate text boxes and then Edit the result in the text box. Editing a text box seems trivial and like anything else in life – it is once you know how!

The following is offered to those just starting out with ASP.NET and would like to Edit a textbox. An example of one test box is given. You can build upon this as you wish or use the elegant solutions offered by Rick and Bonnie.

You can use C sharp if you wish - my example is what I used to get the puppy to work.
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        ' Save…
        Dim userID As String = ddlUsersID.SelectedItem.Value
        UpdateUser(userID, txtPhoneExt.Text)

End sub

' Update a record...

    Sub UpdateUser(ByVal userID As String, ByVal PhoneExt As String)
        Dim sql As String = "UPDATE UserInfo SET PhoneExt=@PhoneExt WHERE userID=@userID"
        Dim cmd As New SqlCommand(sql, SqlConnection1)
        cmd.Parameters.Add("@PhoneExt", PhoneExt)
        cmd.Parameters.Add("@UserID", userID)


        If SqlConnection1.State = ConnectionState.Closed Then SqlConnection1.Open()
        cmd.ExecuteNonQuery()

        
    End Sub
Tom
Répondre
Fil
Voir

Click here to load this message in the networking platform