Class UserEditViewModel
- Namespace
- Dynamicweb.Users.Frontend.UserEdit
- Assembly
- Dynamicweb.Users.dll
View model for the UserEdit frontend module.
public sealed class UserEditViewModel : ViewModelBase
- Inheritance
-
UserEditViewModel
- Inherited Members
- Extension Methods
Examples
Razor template usage:
@inherits ViewModelTemplate<Dynamicweb.Users.Frontend.UserEdit.UserEditViewModel> @using Dynamicweb.Users.Frontend.UserEdit
@{ var updateAction = Model.GetEditUserLink(Pageview.Page.ID); var deleteAction = Model.GetDeleteUserLink(Pageview.Page.ID); }
<form method="post" action="@updateAction"> <label for="Email">Email</label> <input type="email" id="Email" name="Email" value="@Model.User.Email" required />
<label for="Name">Name</label> <input type="text" id="Name" name="Name" value="@Model.User.Name" />
@* Optional: selectable groups *@ @if (Model.SelectableUserGroups?.Any() == true) { <fieldset> <legend>Groups</legend> @foreach (var g in Model.SelectableUserGroups) { <label><input type="checkbox" name="UserGroupIds" value="@g.Id" /> @g.Name</label> } </fieldset> }
<button type="submit">Save changes</button> @if (Model.Result != UserEditResultType.None) { <p class="form-message">@Translate(Model.Result.ToString())</p> } </form>
<form method="post" action="@deleteAction" onsubmit="return confirm('Delete your account?');"> <button class="btn btn-danger" type="submit">Delete account</button> </form>
Remarks
This model is provided to Razor templates in /Templates/Users/UserEdit/Edit.
It exposes the user being edited, an optional list of selectable groups, and the result of the most recent operation.
Templates typically render a form that posts to
UserEditViewModelExtensions.GetEditUserLink(model, pageId) and use
Result to display success/error messages. A separate POST can target
GetDeleteUserLink for account deletion.
Properties
Result
Gets or sets the outcome of the most recent operation.
public UserEditResultType Result { get; set; }
Property Value
Remarks
Use this to render success/error feedback; values include None, Success, and InvalidEmail.
SelectableUserGroups
Gets or sets the groups the editor has made selectable for this page.
public IEnumerable<UserGroupViewModel> SelectableUserGroups { get; set; }
Property Value
Remarks
If you render a checkbox list and post the selected IDs (e.g., UserGroupIds),
the module updates the user’s group relations accordingly.
User
Gets or sets the user being edited (as a nested UserViewModel).
Bind your form inputs to these properties (e.g., Email, Name, address and phone fields).
public required UserViewModel User { get; set; }