Ektron CMS400.NET API Documentation
|
Adds a new membership user to CMS.
public UserData AddMembershipUser(UserData udUserData);
Public Function AddMembershipUser(ByVal udUserData As UserData) As UserData
Parameters |
Description |
udUserData |
An object of class which represents the corresponding user elements. |
Ektron.Cms.UserData
The following example shows how to create a Web page from which a new membership user can be added. This example uses some standard drag and drop controls and a small section of VB code utilizing the AddMembershipUser method. This method uses the InternalAdmin to add the Membership User. In the first section, we will deal with the standard drag and drop controls. In the second, we'll deal with the code behind.
1. Between the form tags, create a table with four rows and three columns. 2. In the first row, first column, add a label that shows where to enter the membership user's Email address. <asp:Label ID="Label6" runat="server" Text="Email: " Width="76px"></asp:Label> 3. In the first row, second column, add a text box to enter the Email address. <asp:TextBox ID="txtEmail" runat="server" Width="144px"></asp:TextBox> 4. In the first row, third column, add a RequiredFieldValidator control from the Validation control menu. This validates that something appears in the Email address box. <asp:RequiredFieldValidator ID="rfvEmail" runat="server" ErrorMessage="Please enter an Email address" ControlToValidate="txtEmail" Display="Dynamic">Please enter email address</asp:RequiredFieldValidator> 5. In the same table cell, add a RegularExpressionValidator control. This validates the information entered is in the format of an Email address. <asp:RegularExpressionValidator ID="rfvEmailFormat" ControlToValidate="txtEmail" runat="server" ErrorMessage="Please enter a valid email address" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Width="236px" ></asp:RegularExpressionValidator> 6. In the second row, first column, add a label to show where to enter a first name. <asp:Label ID="Label4" runat="server" Text="First name: " Width="76px"></asp:Label> 7. In the second row, second column, add a text box to enter the fist name. <asp:TextBox ID="txtFirstName" runat="server" Width="144px"></asp:TextBox> 8. In the second row, third column, add a RequiredFieldValidator control from the Validation control menu. This validates that something appears in the first name box. <asp:RequiredFieldValidator ID="rfvFirstName" runat="server" ErrorMessage="Please enter first name" ControlToValidate="txtFirstName">Please enter first name</asp:RequiredFieldValidator> 9. In the third row, first column, add a label to show where to enter a last name. <asp:Label ID="Label7" runat="server" Text="Last Name:" Width="76px"></asp:Label> 10. In the third row, second column, add a text box to enter the last name. <asp:TextBox ID="txtLastName" runat="server" Width="144px"></asp:TextBox> 11. In the third row, third column, add a RequiredFieldValidator control from the Validation control menu. This validates that something appears in the last name box. <asp:RequiredFieldValidator ID="rfvLastName" runat="server" ErrorMessage="Please enter last name" ControlToValidate="txtLastName">Please enter last name</asp:RequiredFieldValidator> 12. In the fourth row, first column, add a label to show where to enter a password. <asp:Label ID="Label8" runat="server" Text="Password: " Width="76px"></asp:Label> 13. In the fourth row, second column, add a text box to enter the password. <asp:TextBox ID="txtPassword" runat="server" TextMode="Password" Width="144px"></asp:TextBox> 14. In the fourth row, third column, add a RequiredFieldValidator control from the Validation control menu. This validates that something appears in the password box. <asp:RequiredFieldValidator ID="rfvPassword" runat="server" ErrorMessage="Please enter password" ControlToValidate="txtPassword">Please enter password</asp:RequiredFieldValidator> 15. After the table, add a break and then add a button to submit the membership user's information. <br /> <asp:Button ID="btnAdd" runat="server" Text="Add Membership User" Width="153px" /> 16. Add two breaks for spacing purposes. <br /><br /> 17. Add a results label to display a message stating the membership user was added and the new ID. <asp:Label ID="lblResult" runat="server"></asp:Label>
Add the following information to the code behind of your aspx.vb page.
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim memDetails As New Ektron.Cms.UserData
Dim newMemUser As New Ektron.Cms.UserData
Dim userAPI As New Ektron.Cms.API.User.User
Dim newMemUserId As Integer
memDetails.Username = txtEmail.Text memDetails.FirstName = txtFirstName.Text memDetails.LastName = txtLastName.Text memDetails.Password = txtPassword.Text
Try
newMemUser = userAPI.AddMembershipUser(memDetails)
newMemUserId = newMemUser.Id
If (newMemUserId > 0) Then lblResult.Text = "The membership user " & txtEmail.Text & " was added into CMS400.Net with UserID = " & newMemUserId End If
Catch ex As Exception lblResult.Text = ex.Message End Try End Sub
Copyright (c) 2008. All rights reserved.
|
What do you think about this topic? Send feedback!
|