Bonjour,

j'ai un soucis: j'ai mon CreateUserWizard qui ne rentre aucune information dans Membership contrairement à l'exemple.

J'ai vu la page suivante et trouvé le code très intéressant.

J'ai donc fait ma propre version du truc pour un projet Web (en allemand en plus ><) mais bien sûr cela ne marche pas... Mais pas un message d'erreur, rien à se mettre sous la dent.

Peut-on seulement me dire pourquoi?

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
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server" BackColor="#F7F6F3" BorderColor="#E6E2D8"
            BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="0.8em" 
            OnNextButtonClick="CreateUserWizard1_NextButtonClick"
            OnCreatedUser="CreateUserWizard1_CreatedUser" ContinueDestinationPageUrl="~/Default.aspx">
            <WizardSteps>
               <asp:WizardStep ID="CreateUserWizardStep0" runat="server">
                    <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                         <tr>
                             <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                 Select an Account Name</td>
                         </tr>
                         <tr>
                             <td>
                               <asp:Label ID="AccountNameLabel" runat="server" AssociatedControlID="SearchAccount" > 
                                 Account Name:</asp:Label>
                               <asp:TextBox ID="SearchAccount" runat="server"></asp:TextBox><br />
                               <asp:Label ID="SearchAccountMessage" runat="server" ForeColor="red" />                                          
                             </td>
                         </tr>
                     </table>
                </asp:WizardStep>
                <asp:CreateUserWizardStep ID="CreateUserWizardStep3" runat="server">
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana">
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d">
                                    Sign Up for Your New Account</td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">
                                        User Name:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="UserName" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
                                        ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password">
                                        Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Password" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
                                        ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="ConfirmPasswordLabel" runat="server" AssociatedControlID="ConfirmPassword">
                                        Confirm Password:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="ConfirmPassword" runat="server" TextMode="Password"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="ConfirmPasswordRequired" runat="server" ControlToValidate="ConfirmPassword"
                                        ErrorMessage="Confirm Password is required." ToolTip="Confirm Password is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="EmailLabel" runat="server" AssociatedControlID="Email">
                                        E-mail:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Email" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="EmailRequired" runat="server" ControlToValidate="Email"
                                        ErrorMessage="E-mail is required." ToolTip="E-mail is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="QuestionLabel" runat="server" AssociatedControlID="Question">
                                        Security Question:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Question" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="QuestionRequired" runat="server" ControlToValidate="Question"
                                        ErrorMessage="Security question is required." ToolTip="Security question is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="right">
                                    <asp:Label ID="AnswerLabel" runat="server" AssociatedControlID="Answer">
                                        Security Answer:</asp:Label></td>
                                <td>
                                    <asp:TextBox ID="Answer" runat="server"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="AnswerRequired" runat="server" ControlToValidate="Answer"
                                        ErrorMessage="Security answer is required." ToolTip="Security answer is required."
                                        ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2">
                                    <asp:CompareValidator ID="PasswordCompare" runat="server" ControlToCompare="Password"
                                        ControlToValidate="ConfirmPassword" Display="Dynamic" ErrorMessage="The Password and Confirmation Password must match."
                                        ValidationGroup="CreateUserWizard1"></asp:CompareValidator>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" colspan="2" style="color: red">
                                    <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
                                </td>
                            </tr>
                        </table>
                        <asp:CheckBox ID="SubscribeCheckBox" runat="server" Checked="True" Text="Send me a monthly newsletter." />
                        <br />
                        <asp:CheckBox ID="ShareInfoCheckBox" runat="server" Checked="True" Text="Share my information with partner sites." />
                    </ContentTemplate>
                </asp:CreateUserWizardStep>
                <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
                    <ContentTemplate>
                        <table border="0" style="font-size: 100%; font-family: Verdana" id="TABLE1" >
                            <tr>
                                <td align="center" colspan="2" style="font-weight: bold; color: white; background-color: #5d7b9d; height: 18px;">
                                    Complete</td>
                            </tr>
                            <tr>
                                <td>
                                    Your account has been successfully created.<br />
                                    <br />
                                    <asp:Label ID="SubscribeLabel" runat="server" Text="You have elected to receive our monthly newsletter."></asp:Label><br />
                                    <br />
                                    <asp:Label ID="ShareInfoLabel" runat="server" Text="You have elected to share your information with partner sites."></asp:Label></td>
                            </tr>
                            <tr>
                                <td align="right" colspan="2">
                                    &nbsp;<asp:Button ID="ContinueButton" runat="server" BackColor="#FFFBFF" BorderColor="#CCCCCC"
                                        BorderStyle="Solid" BorderWidth="1px" CausesValidation="False" CommandName="Continue"
                                        Font-Names="Verdana" ForeColor="#284775" Text="Continue" ValidationGroup="CreateUserWizard1" />
                                </td>
                            </tr>
                        </table>
                    </ContentTemplate>
                </asp:CompleteWizardStep>
            </WizardSteps>
            <SideBarStyle BackColor="#5D7B9D" BorderWidth="0px" Font-Size="0.9em" VerticalAlign="Top" />
            <TitleTextStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
            <SideBarButtonStyle BorderWidth="0px" Font-Names="Verdana" ForeColor="White" />
            <NavigationButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <HeaderStyle BackColor="#5D7B9D" BorderStyle="Solid" Font-Bold="True" Font-Size="0.9em"
                ForeColor="White" HorizontalAlign="Center" />
            <CreateUserButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <ContinueButtonStyle BackColor="#FFFBFF" BorderColor="#CCCCCC" BorderStyle="Solid"
                BorderWidth="1px" Font-Names="Verdana" ForeColor="#284775" />
            <StepStyle BorderWidth="0px" />
        </asp:CreateUserWizard>
</div>

Code VB : 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
Partial Class _Default
    Inherits System.Web.UI.Page
 
    Public Sub CreateUserWizard1_CreatedUser(ByVal sender As Object, ByVal e As EventArgs)
        ' Determine the checkbox values.
        'Dim subscribeCheckBox As CheckBox = _
        '  CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("SubscribeCheckBox"), CheckBox)
        'Dim shareInfoCheckBox As CheckBox = _
        '  CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("ShareInfoCheckBox"), CheckBox)
 
        Dim F_UserName As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("UserName"), TextBox)
        Dim F_Email As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Email"), TextBox)
        Dim F_Question As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Question"), TextBox)
        Dim F_Answer As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Answer"), TextBox)
        Dim F_Password As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Password"), TextBox)
        Dim F_Name As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Name"), TextBox)
        Dim F_Vorname As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Vorname"), TextBox)
        Dim F_Geschlecht As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Geschlecht"), TextBox)
        Dim F_Datum As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Datum"), TextBox)
        Dim F_Jahrgang As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Jahrgang"), TextBox)
        Dim F_Studiengang As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Studiengang"), TextBox)
        Dim F_Kontingent As TextBox = _
            CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Kontingent"), TextBox)
        Dim IsCreated As MembershipCreateStatus
 
        'Dim user As MembershipUser = Membership.GetUser(userNameTextBox.Text)
        'User.Comment = "Subscribe=" & subscribeCheckBox.Checked.ToString() & "&" & _
        '               "ShareInfo=" & shareInfoCheckBox.Checked.ToString()
 
        Membership.CreateUser(F_UserName.Text, F_Password.Text, F_Email.Text, F_Question.Text, F_Answer.Text, True, IsCreated)
        Dim user As MembershipUser = Membership.GetUser(F_UserName.Text)
        Membership.UpdateUser(user)
        ' Das Geschlecht und Kontingent in boolean konvertieren
        Dim F_Geschlecht2 As Boolean
        Dim F_Kontingent2 As Boolean
        If F_Geschlecht.Text = "Maennlich" Then
            F_Geschlecht2 = False
        Else
            F_Geschlecht2 = True
        End If
        If F_Kontingent.Text = "Metz" Then
            F_Kontingent2 = False
        Else
            F_Kontingent2 = True
        End If
 
        ' Das Schluessel vom dem neuen User nehmen
        Dim key As New System.Guid
        key = Membership.GetUser(F_UserName.Text).ProviderUserKey
 
        ' Dann die Tabelle aspnet_custom_Student einfuellen
        Dim ds As New DataSet1TableAdapters.aspnet_custom_StudentTableAdapter
        'ds.InsertStudent(key, F_Name.Text, F_Vorname.Text, F_Geschlecht2, F_Datum.Text, F_Jahrgang.Text, F_Studiengang.Text, F_Kontingent2)
 
        ' Show or hide the labels based on the checkbox values.
        'Dim subscribeLabel As Label = _
        '  CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("SubscribeLabel"), Label)
        'Dim shareInfoLabel As Label = _
        '  CType(CreateUserWizard1.CompleteStep.ContentTemplateContainer.FindControl("ShareInfoLabel"), Label)
 
        'subscribeLabel.Visible = subscribeCheckBox.Checked
        'shareInfoLabel.Visible = shareInfoCheckBox.Checked
 
        'ds.Insert(
 
        'Membership.GetUser(True).ProviderUserKey.ToString()
    End Sub
 
    Private Function UserExists(ByVal username As String) As Boolean
        If Membership.GetUser(username) IsNot Nothing Then Return True
 
        Return False
    End Function
 
    Protected Sub CreateUserWizard1_NextButtonClick(ByVal sender As Object, ByVal e As WizardNavigationEventArgs)
 
        'Dim TB_Login As TextBox = _
        'CType(CreateUserWizardStep0.ContentTemplateContainer.FindControl("UserName"), TextBox)
        'Dim SearchAccountMessage As Label = _
        'CType(CreateUserWizardStep0.ContentTemplateContainer.FindControl("SearchAccountMessage"), Label)
 
        'Fuer die Ueberpruefung der Daten
        If e.CurrentStepIndex = 2 Then
            'Man nimmt die gebrauchte TextBox
            Dim TB_Name As TextBox = _
                CType(CreateUserWizardStep0.FindControl("TB_Name"), TextBox)
            Dim TB_Vorname As TextBox = _
                CType(CreateUserWizardStep0.FindControl("TB_Vorname"), TextBox)
            Dim CB_Geschlecht As CheckBox = _
                CType(CreateUserWizardStep0.FindControl("CB_Geschlecht_M"), CheckBox)
            Dim TB_Datum As TextBox = _
                CType(CreateUserWizardStep0.FindControl("TB_Datum"), TextBox)
            Dim TB_Jahrgang As TextBox = _
                CType(CreateUserWizardStep0.FindControl("TB_Jahrgang"), TextBox)
            Dim LB_Studiengang As ListBox = _
                CType(CreateUserWizardStep0.FindControl("LB_Studiengang"), ListBox)
            Dim CB_Kontingent As CheckBox = _
                CType(CreateUserWizardStep0.FindControl("CB_Kontingent_M"), CheckBox)
            Dim TB_Login As TextBox = _
                CType(CreateUserWizardStep1.FindControl("TB_Login"), TextBox)
            Dim TB_Email As TextBox = _
                CType(CreateUserWizardStep1.FindControl("TB_Email"), TextBox)
            Dim TB_Question As TextBox = _
                CType(CreateUserWizardStep1.FindControl("TB_Question"), TextBox)
            Dim TB_Answer As TextBox = _
                CType(CreateUserWizardStep1.FindControl("TB_Answer"), TextBox)
            Dim TB_Password As TextBox = _
                CType(CreateUserWizardStep1.FindControl("TB_Password"), TextBox)
 
            Dim F_UserName As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("UserName"), TextBox)
            Dim F_Email As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Email"), TextBox)
            Dim F_Question As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Question"), TextBox)
            Dim F_Answer As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Answer"), TextBox)
            Dim F_Password As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Password"), TextBox)
            Dim F_Name As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Name"), TextBox)
            Dim F_Vorname As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Vorname"), TextBox)
            Dim F_Geschlecht As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Geschlecht"), TextBox)
            Dim F_Datum As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Datum"), TextBox)
            Dim F_Jahrgang As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Jahrgang"), TextBox)
            Dim F_Studiengang As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Studiengang"), TextBox)
            Dim F_Kontingent As TextBox = _
                CType(CreateUserWizardStep3.ContentTemplateContainer.FindControl("Kontingent"), TextBox)
 
            'Man gibt die Werte der TextBox zu den neuen TextBox
            F_UserName.Text = TB_Login.Text
            F_Email.Text = TB_Email.Text
            F_Question.Text = TB_Question.Text
            F_Answer.Text = TB_Answer.Text
            F_Password.Text = TB_Password.Text
            F_Name.Text = TB_Name.Text
            F_Vorname.Text = TB_Vorname.Text
            F_Datum.Text = TB_Datum.Text
            F_Jahrgang.Text = TB_Jahrgang.Text
            F_Studiengang.Text = LB_Studiengang.SelectedItem.Value
 
            If CB_Geschlecht.Checked Then
                F_Geschlecht.Text = "Maennlich"
            Else
                F_Geschlecht.Text = "Weiblich"
            End If
            If CB_Kontingent.Checked Then
                F_Kontingent.Text = "Metz"
            Else
                F_Kontingent.Text = "Saarbruecken"
            End If
 
        End If
        'If e.CurrentStepIndex = 4 Then
        'CreateUserWizard1_CreatedUser(sender, e)
        'End If
 
        'If e.CurrentStepIndex = 0 Then
        'If TB_Login.Text.Trim() = "" Then
        'SearchAccountMessage.Text = "Ihre Login darf nicht leer sein."
        'e.Cancel = True
        'ElseIf UserExists(TB_Login.Text) Then
        'SearchAccountMessage.Text = "Diese Login ist schon benutzt. Bitte auswählen Sie ein andere Login."
        'e.Cancel = True
        'Else
        '   Dim userName As TextBox = _
        'CType(CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("UserName"), TextBox)
        'userName.Text = TB_Login.Text
        'SearchAccountMessage.Text = ""
        e.Cancel = False
        'End If
        'End If
    End Sub
 
End Class

Je remercie tout sauveur potentiel et suis prêt à lui masser les pieds s'il le faut.

PS: En faisant des tests sur le code du lien, j'ai remarqué que l'insertion dans la base de données ne se faisait plus si on supprimait le contenu de CreateUserWizard1_NextButtonClick mais je ne vois pas du tout pourquoi.

Dieu d'ASP, si tu existes, pardonne mes pêchés et aide-moi s'il-te-plaît.