Asp.net core : Display multiselect options based on another multiselect without page reload

Last Reply 9 days ago By AjayV

Posted 10 days ago

How do I generate the list of UserIDs based on what the user click in the multiselect with id lstUserGroups without page reloading and button clicking? I can't use AJAX because there is no internet.

<form method="post">
        <div id="search_cont">
            <div class="d-flex align-items-center mb-4">
                <label for="dropdownSelectGrp">
                    User Group:
                </label>
                <div class="ms-3 w-50">
                    <select id="lstUserGroups" name="lstUserGroups" asp-items="@Model.lst_UserGroupModel" multipleclass="form-control" multiple>
                    </select>
                </div>

                <label for="dropdownSelectID" class="ms-4">
                    User ID:
                </label>
                <div class="dropdown ms-3 w-25">
                    <select id="dropdownSelectID" name="UserID" aria-expanded="true" multiclass="form-select" multiple>
                    </select>
                </div>
                <button type="submit" asp-page-handler="Submit" class="btn btn-primary ms-3 text-uppercase">Search</button>
            </div>
        </div>
</form>

 

        public void OnGet(string id)
        {
            // retrieve UserGroup ID and name for display
            lst_UserGroupModel = (from item in _IUserGrp.GetUserGroupList()
                                  select new SelectListItem {
                                      Text  = item.UserGroupName,
                                      Value = item.UserGrpID.ToString()
                                  }).ToList();

            if (!string.IsNullOrEmpty(id))
            {
                //UserGrpFunctionTableModel = _IUserGrpFnc.GetData(0);
                //lst_AccessFunctions = _IUserGrpFnc.GetUserGroupFunctions(id);
            }
        }

        public void OnGetUsers(string[] userGroupIds)
        {
             // retrieve based on GroupIDs selected on display onto dropdownSelectID multiselect
        }

 

You are viewing reply posted by: AjayV 9 days ago.