Table of Contents

Edit User

For users to edit and update user information, or to delete user account

The Edit Users app makes it possible for users from the frontend to edit and update user information, or to delete their user account:

Edit user

You must:

  • Select an Edit user template
  • Select a Change Password page, which can be linked to

Edit User template

The Edit User template should inherit the UserViewModel and use the Dynamicweb.Rendering and Dynamicweb.Frontend namespaces.

Create a form with properties from the ViewModel that displays the user information the user should be able to edit. To execute either an update of user information, deletion of user account or link to the selected change password page, submit an URL with the UserCmd and a set of parameters and values appropriate for the user command:

@inherits ViewModelTemplate<UserViewModel>
@using Dynamicweb.Rendering
@using Dynamicweb.Frontend

<!-- Create the URL's with the appropriate UserCmd -->
@{
    string updateUserLink = $"/Default.aspx?ID={Pageview.Page.ID}&amp;UserCmd=updateuser";
    string deleteUserLink = $"/Default.aspx?ID={Pageview.Page.ID}&amp;UserCmd=deleteuser";
    string changePasswordLink = $"/Default.aspx?ID={Pageview.Page.ID}&amp;UserCmd=changepassword";
}

<!-- Link to change password page with UserCmd -->
<a href="@changePasswordLink">Change password</a>

<!-- Create a form that displays properties from the ViewModel-->
<form action="@updateUserLink" method="post">
    <input type="hidden" name="ID" value="@Pageview.ID">
    <div>
            <input type="text" placeholder="Name" name="Name" id="Name" value="@Model.Name">
            <label for="Name">Name</label>
            <input type="email" placeholder="Email" name="Email" id="Email" value="@Model.Email" required />
            <label for="Email">Email</label>
    </div>
    <div>
        <!-- Create buttons for saving user information and for deleting the user account with UserCmd-->
        <button type="submit" id="SaveUserButton">Save</button>
        <a href="@deleteUserLink" id="DeleteUserButton">Delete</a>
    </div>
</form>
To top