Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question<%@ Page Language="vb" AutoEventWireup="false" Codebehind="checkbox dynamique.aspx.vb" Inherits="TestExemple.checkbox_dynamique" trace="true"%> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>checkbox_dynamique</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" > <meta http-equiv="Content-Script-Type" content="text/javascript" > <meta http-equiv="Content-Style-Type" content="text/css" > <meta http-equiv="Content-Language" content="fr" > <meta name="http.language" CONTENT="French"> <meta name="robots" content="index,follow" > <meta name="description" content="ici la description du site"> <meta name="keywords" content="ici les mots clés"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name=vs_defaultClientScript content="JavaScript"> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> </head> <form id="Form1" method="post" runat="server"> </form> </html>
Imports System.IO Public Class checkbox_dynamique Inherits System.Web.UI.Page #Region " Code généré par le Concepteur Web Form " 'Cet appel est requis par le Concepteur Web Form. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Protected WithEvents Table1 As System.Web.UI.WebControls.Table 'REMARQUE : la déclaration d'espace réservé suivante est requise par le Concepteur Web Form. 'Ne pas supprimer ou déplacer. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form 'Ne le modifiez pas en utilisant l'éditeur de code. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Placez ici le code utilisateur pour initialiser la page Dim Row As New TableRow Dim i As Integer = 0 Dim Cell As New TableCell For Each File As String In System.IO.Directory.GetFiles(Server.MapPath("")) Dim FI As New FileInfo(File) Cell = New TableCell Dim Check As New CheckBox Check.ID = "check" & FI.Name Check.Checked = IIf(2 * Rnd() > 1, True, False) Cell.Controls.Add(Check) Dim Literal As New Literal Literal.Text = FI.Name Cell.Controls.Add(Literal) Row.Cells.Add(Cell) i += 1 If i = 3 Then i = 0 Table1.Rows.Add(Row) Row = New TableRow End If Next Row = New TableRow Dim LeBouton As New Button LeBouton.Text = "valider" 'On lie le click du bouton à l'evenement on l'ajoute au placeholder AddHandler LeBouton.Click, AddressOf LeBouton_Click Cell = New TableCell cell.Controls.Add(LeBouton) Row.Cells.Add(cell) Table1.Rows.Add(Row) Table1.DataBind() Table1.Dispose() End Sub Private Sub LeBouton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Dim Coll As Collections.Specialized.NameValueCollection = Request.Form Dim Al As New ArrayList For Each c As String In Coll If Left(c, 5) = "check" Then Response.Write(c & " ") Al.Add(c) End If Next Session("CheckBox") = Al Response.Redirect("RecupCheckbox.aspx") End Sub End Class
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="RecupCheckbox.aspx.vb" Inherits="TestExemple.RecupCheckbox" trace="true"%> <%@ Register TagPrefix="uc1" TagName="RecupCheckcboxControle" Src="RecupCheckcboxControle.ascx" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>RecupCheckbox</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" > <meta http-equiv="Content-Script-Type" content="text/javascript" > <meta http-equiv="Content-Style-Type" content="text/css" > <meta http-equiv="Content-Language" content="fr" > <meta name="http.language" CONTENT="French"> <meta name="robots" content="index,follow" > <meta name="description" content="ici la description du site"> <meta name="keywords" content="ici les mots clés"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1"> <meta name=vs_defaultClientScript content="JavaScript"> <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5"> </head> <form id="Form1" method="post" runat="server"> </form> </html>
Public Class RecupCheckbox Inherits System.Web.UI.Page #Region " Code généré par le Concepteur Web Form " 'Cet appel est requis par le Concepteur Web Form. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Protected WithEvents Table1 As System.Web.UI.WebControls.Table 'REMARQUE : la déclaration d'espace réservé suivante est requise par le Concepteur Web Form. 'Ne pas supprimer ou déplacer. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form 'Ne le modifiez pas en utilisant l'éditeur de code. InitializeComponent() End Sub #End Region Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Placez ici le code utilisateur pour initialiser la page Dim Al As ArrayList = Session("CheckBox") Dim Row As TableRow 'Cellule avec le texte selectionner Dim Cell1 As TableCell '1er drop Dim Cell2 As TableCell Dim Drop2 As DropDownList '2eme drop Dim Cell3 As TableCell Dim drop3 As DropDownList For Each s As String In Al Row = New TableRow Cell1 = New TableCell Dim Ligne As New RecupCheckcboxControle Ligne = LoadControl("RecupCheckcboxControle.ascx") Ligne.ID = s.Substring(5) Cell1.Controls.Add(Ligne) Row.Cells.Add(Cell1) Table1.Rows.Add(Row) Next Row = New TableRow Cell1 = New TableCell Dim Valid As New Button Valid.Text = "Valider" AddHandler Valid.Click, AddressOf Valid_Click Cell1.Controls.Add(Valid) Row.Cells.Add(Cell1) Table1.Rows.Add(Row) Table1.DataBind() End Sub Private Sub Valid_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) End Sub End Class
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="RecupCheckcboxControle.ascx.vb" Inherits="TestExemple.RecupCheckcboxControle" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %> <td style="WIDTH: 66px">
Public Class RecupCheckcboxControle Inherits System.Web.UI.UserControl #Region " Code généré par le Concepteur Web Form " 'Cet appel est requis par le Concepteur Web Form. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent() End Sub Protected WithEvents Dropdownlist1 As System.Web.UI.WebControls.DropDownList Protected WithEvents Dropdownlist2 As System.Web.UI.WebControls.DropDownList Protected WithEvents Dropdownlist3 As System.Web.UI.WebControls.DropDownList Protected WithEvents imgPhot As System.Web.UI.WebControls.ImageButton Protected WithEvents qte As System.Web.UI.WebControls.TextBox 'REMARQUE : la déclaration d'espace réservé suivante est requise par le Concepteur Web Form. 'Ne pas supprimer ou déplacer. Private designerPlaceholderDeclaration As System.Object Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init 'CODEGEN : cet appel de méthode est requis par le Concepteur Web Form 'Ne le modifiez pas en utilisant l'éditeur de code. InitializeComponent() End Sub #End Region Private Name As String Public Property Nom() As String Get Return Name End Get Set(ByVal Value As String) Name = Value End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Placez ici le code utilisateur pour initialiser la page imgPhot.AlternateText = Me.ID Response.Write(Dropdownlist1.SelectedValue & " ") If Not Page.IsPostBack Then BindData_DropDownlist1() BindData_DropDownlist2() BindData_DropDownlist3() End Sub Private Sub BindData_DropDownlist1() Dropdownlist1.DataSource = Split("10*15,13*18,casquette", ",") Dropdownlist1.DataBind() End Sub Private Sub BindData_DropDownlist2() Select Case Dropdownlist1.SelectedValue Case "10*15" Dropdownlist2.DataSource = Split("brillant,mat", ",") Case "13*18" Dropdownlist2.DataSource = Split("brillant 13*18,mat 13*18", ",") Case "casquette" Dropdownlist2.DataSource = Split("L,XL,XXL", ",") End Select Dropdownlist2.DataBind() End Sub Private Sub BindData_DropDownlist3() Select Case Dropdownlist1.SelectedValue Case "10*15" Select Case Dropdownlist2.SelectedValue Case "brillant" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") Case "mat" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") End Select Case "13*18" Select Case Dropdownlist2.SelectedValue Case "brillant 13*18" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") Case "mat 13*18" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") End Select Case "casquette" Select Case Dropdownlist2.SelectedValue Case "L" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") Case "XL" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") Case "XXL" Dropdownlist3.DataSource = Split("Valeur1,Valeur2", ",") End Select End Select Dropdownlist3.DataBind() End Sub Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) BindData_DropDownlist2() End Sub Private Sub DropDownList2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) BindData_DropDownlist3() End Sub End Class