$("#dropdown").on("change keyup", function() {
var selected = $(this).val();
$.post("/Controller/AssignRole", {selectedRole: selected}, function(data) {
//data is the value returned by your action method.
//example: partial view, or status message
$("#status").html(data); //success message
});
});
Ajax.form dropdownlist to change user role
-
01-07-2023 - |
Question
Could you give some simple example of how to create form that consists of only dropdownlist?
I want to use it to create admin-side user management to assign users to one role, with aspnet mvc simplemembership. I mean step by step: - list all registered users (DONE) - next to their nicks show dropdown list; selected value is user's current role using
Roles.AddUserToRole(item.UserName, "RoleName");
- by changing dropdown value assign user to new role (overwrite old one) with ajax (don't reload page, just show for few seconds success/error status)
Anyway, I'd like similar example how to do it, it doesn't have to be code I exactly need to produce.
Many thanks in advance.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow