Href onclick vb.net

Jessica - Modifié par Jessica le 8/07/2014 à 10:39
jordane45 Messages postés 38137 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 - 8 juil. 2014 à 10:38
Bonjour,

Je voudrais appeler la fonction VB.net en appuyant sur liens hypertexte
exemple
html :
 <a id="A1" href="#" runat="server"  onclick="ObtNoTracking()" >NoTracking</a>

cote serveur, vb.net :
 Sub ObtNoTracking()
        'On récupère les éléments de la base de donees 
        Dim maConnexion As New SqlConnection
        Dim req As String
        'Connexion à la base SQL
        maConnexion.ConnectionString = ...
        maConnexion.Open()

        'Lien 1
        If ... Then
            req = "..."
            maConnexion.Open()
            Dim myCommand0 As New SqlCommand(req, maConnexion)
            Dim myReader0 As SqlDataReader = myCommand0.ExecuteReader()
            myReader0.Read()

            If myReader0.HasRows <> False Then
                If Not IsDBNull(myReader0(0)) Then A1.HRef = "[http://] ..."
            End If
            myReader0.Close()
            maConnexion.Close()
        End If

        ' Lien 2
        If .. Then
            req = ".."
            maConnexion.Open()
            Dim myCommand1 As New SqlCommand(req, maConnexion)
            Dim myReader1 As SqlDataReader = myCommand1.ExecuteReader()
            myReader1.Read()

            If myReader1.HasRows <> False Then
                If Not IsDBNull(myReader1(0)) Then A1.HRef = myReader1(0)
            End If
            myReader1.Close()
            maConnexion.Close()
        End If

        ' Lien 3
        If ...Then
            req = "..."
            maConnexion.Open()
            Dim myCommand2 As New SqlCommand(req, maConnexion)
            Dim myReader2 As SqlDataReader = myCommand2.ExecuteReader()
            myReader2.Read()

            If myReader2.HasRows <> False Then
                If Not IsDBNull(myReader2(0)) Then A1.HRef = "http://..." & myReader2(0)
            End If
            myReader2.Close()
            maConnexion.Close()
        End If
    End Sub

Mais elle ne fonctionne pas. Comment puis-je résoudre ce problème, à partir de mon code ? Merci pour réponse

1 réponse

jordane45 Messages postés 38137 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 344
8 juil. 2014 à 10:38
Merci de bien vouloir utiliser la coloration syntaxique (les balises de code) lorsque tu postes du code sur le forum.
Explications disponibles ici :
http://codes-sources.commentcamarche.net/faq/10686-le-nouveau-codes-sources-comment-ca-marche#balises-code

J'édite ton message pour les y mettre.
0
Rejoignez-nous