Asp.net website administration tool tutorial
NET references with objects, components, properties and methods. We just launched W3Schools videos. Get certified by completing a course today! If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail:. Report Error. Your message has been sent to W3Schools. W3Schools is optimized for learning and training. The text to search for and the search mode are retrieved from the grid's Attributes collection. Below is the code:.
IsNullOrEmpty gvUsers. Parse gvUsers. Attributes[ "SearchByEmail" ] ; if searchText. This BindAllUsers method is also called when the Search button is clicked. In this case, the search mode will be set according to the value selected in the ddlUserSearchTypes dropdown list control.
If you want to delete a user you have to click the trashcan icon. Inside this event handler you will use the static methods of the Membership and ProfileManager classes to delete the user account and its accompanying profile.
BindAllUser method is called with true as a parameter , so that the collection of all users is refreshed, and the new information is displayed:. ToString ; ProfileManager. DeleteProfile userName ; Membership. If you delete a user you cannot undo this action. This is why you should have the administrator confirm this action before proceeding. Through the button's OnClientClick property you can add a "confirm" JavaScript in the link's onclick client-side event.
All these can be done in the gridview's RowCreated event to get a reference to each link as soon as its parent row and all its contents are created. Controls[0] as ImageButton ; btn. This script is added only for rows of type DataRow. In this way we will avoid to add this script to the header, footer, and pagination bars. After registering every user has to fill in some forms with his profile.
Due to flexibility I grouped all these forms and controls into a user control. In this way I can use the same user control in the administration section to edit the profile for a user. So, the profile proprieties that we configured in web. Please see below the mark-up code for this user control. Profile; if this. GetProfile this. UserName ; txtFirstName. FirstName; txtLastName. LastName; ddlGenders. Gender; if profile.
MinValue txtBirthDate. ToShortDateString ; ddlOccupations. Occupation; txtWebsite. Website; txtStreet. Street; txtCity. City; txtPostalCode. PostalCode; txtState. State; txtPhone. Phone; txtFax. The most important method is the Save method. It has the purpose to save in the user's profile the values from the forms. UserName ; profile. Text; profile. SelectedValue; if txtBirthDate. Parse txtBirthDate. Text ; profile. SelectedValue; profile. It is important that this user control to benefit of the ViewState facility, but we might have problems if we place this user control in a page that has the ViewState disabled.
To resolve this problem we have to use the ControlState facility. It does mainly the same thing like Viewstate, but the difference is that it will be always enabled no matter of the ViewState from the web page. To implement the ControlState facility we have to write the code below:. You can access the EditUsers. The username of that user is passed as a querystring value.
This page allows an administrator to see all the membership details about that user and to edit the user's personal profile.
The user interface of the page is simple and is divided in three parts:. The first part displays the details from MembershipUser. All controls are read-only, except for those that are bound to the IsApproved and IsLockedOut properties. Through the IsLockedOut property you can unlock a user account. The second part contains a CheckBoxList that displays all the roles created for this application. This control has two view templates: Anonymous template and LoggedIn template.
Select each view and write some text for the users to be displayed for each template. The text should be placed on the area marked red. Step 8 : The users for the application are created by the developer. You might want to allow a visitor to create a user account. For this, add a link beneath the LoginView control, which should link to the CreateAccount. Step 9 : Place a CreateUserWizard control on the create account page.
Step 10 : Create the Login page. Place a Login control on the page. The LoginStatus control automatically links to the Login. To change this default, make the following changes in the web. For example, if you want to name your log in page as signup. Step 11 : Users often forget passwords. The PasswordRecovery control helps the user gain access to the account. Select the Login control.
Open its smart tag and click 'Convert to Template'. Customize the UI of the control to place a hyperlink control under the login button, which should link to the PassWordRecovery. Step 12 : Place a PasswordRecovery control on the password recovery page. This control needs an email server to send the passwords to the users.
Step 13 : Create a link to the ChangePassword. Step 14 : Place a ChangePassword control on the change password page. This control also has two views.
0コメント