Bonjour,
J'affiche une fenêtre popup dans ma webform pour faire une saisie. Quand je valide, la popup se ferme or je veux que les champs se vident simplement sans fermer la popup. Je vous met le code

Code asp : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<asp:ScriptManager ID="asm" runat="server"></asp:ScriptManager>
        <asp:Panel ID="ModalPanel" runat="server" Width="300px" BackColor="Azure">
            <div style="text-transform:uppercase;font-size:xx-large;font-weight:bold;background: url(/Images/image3.png) no-repeat right top;color:white;text-align: center;">
                <asp:Label ID="lbl_titre" runat="server" Text="Nouveau véhicule"></asp:Label>
            </div>
            <br />
            <asp:TextBox ID="valeur" runat="server" Width="100%" AutoCompleteType="Disabled" MaxLength="50"></asp:TextBox>
            <br />
            <br />
            <div style="text-align: right">
                <asp:Button CssClass="btn btn-abandon btn-round" ID="Button1" runat="server" Text="Fermer"/>
                <asp:Button CssClass="btn btn-valider btn-round" ID="bt_valider" runat="server" Text="Valider"/>
            </div>
        </asp:Panel>
        <div>
            <asp:Button ID="btn1" runat="server" Text="Edit" />
        </div>
        <ajaxToolkit:ModalPopupExtender ID="mpe" runat="server"
            TargetControlID="btn1" PopupControlID="ModalPanel"/>

en code behind

Code VB.NET : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Protected Sub bt_valider_Click(sender As Object, e As EventArgs) Handles bt_valider.Click
        If ContrainteValiderTextBox(valeur, "Valeur") Then Exit Sub
 
        Try
            Dim Idx = NumeroAutoId()
 
            SqlConn.Open()
            Dim myCommand As New SqlCommand
            myCommand.Connection = SqlConn
            myCommand.CommandText = "insert into p_type_vehicule values (@Idx,@Val,@Supp)"
            myCommand.Parameters.Add(New SqlParameter("@Idx", Idx))
            myCommand.Parameters.Add(New SqlParameter("@Val", valeur.Text))
            myCommand.Parameters.Add(New SqlParameter("@Supp", "False"))
            myCommand.ExecuteNonQuery()
            SqlConn.Close()
            myCommand = Nothing
 
            valeur.Text = ""
            valeur.Focus()
        Catch ex As Exception
            ClientScript.RegisterStartupScript([GetType](), "alert", "<script language=JavaScript>alert('Erreur " & Err.Number & " - " & Err.Description & "');</script>")
        End Try
    End Sub

Code VB.NET : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
Private Function ContrainteValiderTextBox(ByVal bText As TextBox, ByVal bEtiquette As String) As Boolean
        ContrainteValiderTextBox = False
 
        If bText.Text = "" Then
            ClientScript.RegisterStartupScript([GetType](), "alert", "<script language=JavaScript>alert('Entrez une valeur dans le champ " & bEtiquette & "');</script>")
            bText.Focus()
            ContrainteValiderTextBox = True
        End If
    End Function

L'objectif de mon poste est de ne pas fermer la popup au clic sur le bouton "Valider"
Merci d'avance