Я реализовал пользовательский поставщик членства, унаследовав поставщика членства .NETs.Для моего интерфейса используется CreateUserWizard Control, который подключен к моему членству.Я отредактировал шаблон элемента управления CreateUserWizard, поэтому теперь он выглядит следующим образом:
<asp:CreateUserWizard ID="CreateUserWizard1" runat="server"
MembershipProvider="CmsMembershipProvider" BackColor="#E3EAEB"
BorderColor="#E6E2D8" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ContinueDestinationPageUrl="~/Pages/FirstPage.aspx">
<ContinueButtonStyle BackColor="White" BorderColor="#C5BBAF"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#1C5E55" />
<CreateUserButtonStyle BackColor="White" BorderColor="#C5BBAF"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#1C5E55" />
<TitleTextStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<table>
<tr>
<td align="center" colspan="2" class="style3">
<strong>Sign Up for Your New Account</strong></td>
</tr>
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
</td>
<td>
<asp:TextBox ID="UserName" name="usna" 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="DomainLabel" runat="server" AssociatedControlID="Domain">Domain:</asp:Label>
</td>
<td>
<asp:TextBox ID="Domain" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="DomainRequired" runat="server"
ControlToValidate="Domain" ErrorMessage="Domain is required."
ToolTip="Domain is required." ValidationGroup="CreateUserWizard1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color:Red;">
<asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
</ContentTemplate>
<CustomNavigationTemplate>
<table border="0" cellspacing="5" style="width:100%;height:100%;">
<tr align="right">
<td align="right" colspan="0">
<asp:Button ID="StepNextButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CommandName="MoveNext" Font-Names="Verdana" ForeColor="#1C5E55"
Text="Create User" ValidationGroup="CreateUserWizard1" />
</td>
</tr>
</table>
</CustomNavigationTemplate>
</asp:CreateUserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
</asp:CompleteWizardStep>
</WizardSteps>
<FinishNavigationTemplate>
<asp:Button ID="FinishPreviousButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CausesValidation="False" CommandName="MovePrevious" Font-Names="Verdana"
ForeColor="#1C5E55" Text="Previous" />
<asp:Button ID="FinishButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CommandName="MoveComplete" Font-Names="Verdana" ForeColor="#1C5E55"
Text="Finish" />
</FinishNavigationTemplate>
<HeaderStyle BackColor="#666666" BorderColor="#E6E2D8" BorderStyle="Solid"
BorderWidth="2px" Font-Bold="True" Font-Size="0.9em" ForeColor="White"
HorizontalAlign="Center" />
<NavigationButtonStyle BackColor="White" BorderColor="#C5BBAF"
BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana"
ForeColor="#1C5E55" />
<SideBarButtonStyle ForeColor="White" />
<SideBarStyle BackColor="#1C5E55" Font-Size="0.9em" VerticalAlign="Top" />
<StartNavigationTemplate>
<asp:Button ID="StartNextButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CommandName="MoveNext" Font-Names="Verdana" ForeColor="#1C5E55" Text="Next" />
</StartNavigationTemplate>
<StepNavigationTemplate>
<asp:Button ID="StepPreviousButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CausesValidation="False" CommandName="MovePrevious" Font-Names="Verdana"
ForeColor="#1C5E55" Text="Previous" />
<asp:Button ID="StepNextButton" runat="server" BackColor="White"
BorderColor="#C5BBAF" BorderStyle="Solid" BorderWidth="1px"
CommandName="MoveNext" Font-Names="Verdana" ForeColor="#1C5E55" Text="Next" />
</StepNavigationTemplate>
<StepStyle BorderWidth="0px" />
</asp:CreateUserWizard>
У него есть оригинальные цифры минус SecurityQuestion и Answer, но кроме того, у меня есть поле Домен с TextBox.
У меня есть метод переопределения CreateUser, поэтому он выглядит так:
public override MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out MembershipCreateStatus status)
{
ValidatePasswordEventArgs args = new ValidatePasswordEventArgs(username, password, true);
OnValidatingPassword(args);
AccountDB accountDB = new AccountDB();
string usn = username;
string eml = email;
string passSalt = AccountDB.CreateSalt();
string pass = AccountDB.CreatePasswordHash(password, passSalt);
DateTime crtDt = DateTime.Now;
DateTime lstMdfDt = DateTime.Now;
DateTime lstLgnDt = DateTime.Now;
string lstLgnIp = (string)HttpContext.Current.Request.UserHostAddress;
byte isAct = 0;
string cmnt = "komentar";
AccountDetails accountDetails = new AccountDetails(usn, eml, pass, passSalt, crtDt, lstMdfDt, lstLgnDt, lstLgnIp, isAct, cmnt);
if (args.Cancel)
{
status = MembershipCreateStatus.InvalidPassword;
return null;
}
if(RequiresUniqueEmail && !accountDB.IsEmailUnique(email))
{
status = MembershipCreateStatus.DuplicateEmail;
return null;
}
if (!accountDB.IsUsernameUnique(username))
{
status = MembershipCreateStatus.DuplicateUserName;
return null;
}
else
{
status = MembershipCreateStatus.Success;
int idOfInsertedUser = accountDB.InsertAccount(accountDetails);
int lanId = 1;
int pySclId = 1;
int appTypId = 1;
int indSecId = 1;
int thmId = 1;
string appName = "ApplicationName";
// ApplicationDetails applicationDetails = new ApplicationDetails(0,lanId, pySclId, idOfInsertedUser, appTypId, indSecId, thmId, appName);
// ApplicationDB applicationDB = new ApplicationDB();
// int idOfApplication = applicationDB.InsertApplication(applicationDetails);
//DomainDB domainDB = new DomainDB();
// This is where i want to have value of textBox Domain in variable domainName
//DomainDetails domainDetails = new DomainDetails(0, idOfApplication, domainName);
//domainDB.InsertDomain(domainDetails);
return accountDB.GetAccount(idOfInsertedUser);
}
}
Он отлично вставляется в базу данных, но я не могу получить значение TextBox Domain из формы, потому что Create User не отправляет эту переменную.Я нашел несколько примеров, которые говорят, что я мог бы создать еще один шаг в CreateUserWizard, а затем обновить базу данных новыми наборами значений, но я не хочу делать это на другом шаге.Можно ли это сделать за один шаг?