asp-net-mvc-1

Load list of roles for each user in MVC5 razor

两盒软妹~` 提交于 2019-12-13 18:33:24
问题 I am trying to display a row of each user and their roles in the ASP.net MVC application. Users and their roles are stored in ASP.net membership provider table. Using the code below I can display each user and the role they are assigned, but my problem is if the user is in multiple roles then the user gets repeated. I tried making UserRole as List but I am now stuck as I do not know how to add the roles to a list in the code below. Could you please provide me some direction? My viewmodel is :

Invoking particular action on dropdown list selection in MVC

主宰稳场 提交于 2019-12-03 05:41:55
问题 I have a dropdown list in an MVC view. On selection change of dropdown list I want to call specific action method in the controller. What I have done on view is this : <%=Html.DropDownList("ddl", ViewData["AvailableList"] as SelectList, new { onchange = "this.form.action='MyMethod';this.form.submit();" })%> Everything is getting compiled. But a runtime exception is thrown when I change the drop down selection, as "Microsift JScript Runtime Error : Object doesn't support property or method"

Invoking particular action on dropdown list selection in MVC

半腔热情 提交于 2019-12-02 19:03:52
I have a dropdown list in an MVC view. On selection change of dropdown list I want to call specific action method in the controller. What I have done on view is this : <%=Html.DropDownList("ddl", ViewData["AvailableList"] as SelectList, new { onchange = "this.form.action='MyMethod';this.form.submit();" })%> Everything is getting compiled. But a runtime exception is thrown when I change the drop down selection, as "Microsift JScript Runtime Error : Object doesn't support property or method" How can I redirect to specific action on list selection change event? How can I pass parameters to this

post and get with same method signature

a 夏天 提交于 2019-11-27 11:45:55
In my controller I have two actions called "Friends". The one that executes depends on whether or not it's a "get" versus a "post". So my code snippets look something like this: // Get: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Friends() { // do some stuff return View(); } // Post: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Friends() { // do some stuff return View(); } However, this does not compile since I have two methods with the same signature (Friends). How do I go about creating this? Do I need to create just one action but differentiate between a "get" and "post" inside of

post and get with same method signature

≯℡__Kan透↙ 提交于 2019-11-26 15:43:45
问题 In my controller I have two actions called "Friends". The one that executes depends on whether or not it's a "get" versus a "post". So my code snippets look something like this: // Get: [AcceptVerbs(HttpVerbs.Get)] public ActionResult Friends() { // do some stuff return View(); } // Post: [AcceptVerbs(HttpVerbs.Post)] public ActionResult Friends() { // do some stuff return View(); } However, this does not compile since I have two methods with the same signature (Friends). How do I go about