iT邦幫忙

2024 iThome 鐵人賽

DAY 20
0
Modern Web

asp.net core 分層架構快速上手系列 第 21

Day20 修改註冊頁面

  • 分享至 

  • xImage
  •  
  • 修改Register.cshtml樣式

複製已有的Input修改即可。

<form id="registerForm" asp-route-returnUrl="@Model.ReturnUrl" method="post">
    <h2>Create a new account.</h2>
    <hr />
    <div asp-validation-summary="ModelOnly" class="text-danger" role="alert"></div>
    <div class="form-floating mb-3">
        <input asp-for="Input.Email" class="form-control" autocomplete="username" aria-required="true" placeholder="name@example.com" />
        <label asp-for="Input.Email">Email</label>
        <span asp-validation-for="Input.Email" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <input asp-for="Input.Name" class="form-control" placeholder="name@example.com" />
        <label asp-for="Input.Name">Name</label>
        <span asp-validation-for="Input.Name" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <input asp-for="Input.PhoneNumber" class="form-control" placeholder="name@example.com" />
        <label asp-for="Input.PhoneNumber">Phone Number</label>
        <span asp-validation-for="Input.PhoneNumber" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <input asp-for="Input.Password" class="form-control" autocomplete="new-password" aria-required="true" placeholder="password" />
        <label asp-for="Input.Password">Password</label>
        <span asp-validation-for="Input.Password" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <input asp-for="Input.ConfirmPassword" class="form-control" autocomplete="new-password" aria-required="true" placeholder="password" />
        <label asp-for="Input.ConfirmPassword">Confirm Password</label>
        <span asp-validation-for="Input.ConfirmPassword" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <input asp-for="Input.Address" class="form-control" placeholder="name@example.com" />
        <label asp-for="Input.Address">Address</label>
        <span asp-validation-for="Input.Address" class="text-danger"></span>
    </div>
    <div class="form-floating mb-3">
        <select asp-for="Input.Role" asp-items="@Model.Input.RoleList" class="form-select">
            <option disabled selected>-Select Role-</option>
        </select>
    </div>
    <button id="registerSubmit" type="submit" class="w-100 btn btn-lg btn-primary">Register</button>
</form>

https://ithelp.ithome.com.tw/upload/images/20240922/20147438n7cwKYwAtd.png

處理完後再次新增帳號,[AspNetUserRoles]資料表就會依user產生roleId
https://ithelp.ithome.com.tw/upload/images/20240922/20147438hhq5nGwZWQ.png


上一篇
Day19 添加角色與權限控管
下一篇
Day21 設置頁面角色權限
系列文
asp.net core 分層架構快速上手31
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言