actionresult

Javascript, MVC Controller caling and return parameters

情到浓时终转凉″ 提交于 2019-12-12 04:57:37
问题 I am able to call a controller method from Javascript. The controller method has Actionresult as return type. Can someone explain, how to return a populated ArrayList from the called controller method, to the calling javascript? How should the javascript handle the returned arraylist? Regards, Anil 回答1: return your arraylist as... return Json(arraylist); then iterate through like an object array function(result) { $.each(result, function(i, item){ alert(item.title + " : " + item.key); }); 回答2

Display list of data on the basis of roles in MVC asp.net identity

只愿长相守 提交于 2019-12-12 01:53:23
问题 I have a list which shows all the videos uploaded by Admin and Users, But I want to apply some condition to individually display User and Admin uploads list (just want to separate list on the basis of roles). How can i do it? This is the code which displays all the Videos public ActionResult Index() { var videos = db.Videos.Include(v => v.Artist).Include(v => v.Category); return View(videos.ToList()); } 回答1: Here is the video class public class Video { public int Id { get; set; } public

Change button text onclick with condition

爷,独闯天下 提交于 2019-12-11 20:18:59
问题 My aim is to have a button, with default value Block and when the user click on it, it will change the text to Unblock and also after page refresh the text of the button must remain the same, if the text is changed to unblock then after refresh it must remain unblock. What i have tried uptil now is this: View code for Button: input type="submit" value="@ViewBag.SubmitValue" id="Block" style="color: white; background-color: darkred; border-bottom-left-radius: 2px; border-bottom-right-radius:

Compiling scss files in ASP.NET MVC action

ぐ巨炮叔叔 提交于 2019-12-11 17:37:31
问题 are any alternatives for compile .scss files in action in ASP.NET MVC controller? I have /Content folder with two files: main.scss and external.scss. In my controller I'm using NSASS package: public ActionResult GetCss(string scssPath) { string scss = @"@import """ + Server.MapPath(scssPath) + @""";"; var compiler = new SassCompiler(); string compiled = compiler.Compile(source: scss); return Content(compiled.ToString(), "text/css"); } my view: <link href="@Url.Action("GetCss", "Theme", new {

Redirecting in asp.net 5

耗尽温柔 提交于 2019-12-11 11:19:31
问题 I am still learning to work with asp.net and I am trying to redirect to an Edit action in a controller from another controller, but I can’t find out how to make it work. this is what I have return RedirectToAction("Edit", "Worker"); or return RedirectToAction("Edit", "Worker", 25); I need it to be something like this: http://localhost:xxxxx/Worker/Edit/25 回答1: You can do the following return RedirectToAction("Edit", "Worker", new { id = 25}); 回答2: You can pass the route value parameters as

Passing model in collection to actionlink

天大地大妈咪最大 提交于 2019-12-11 10:37:26
问题 I feel like this is a pretty basic question. What I am trying to achieve is display a collection of objects as links. When I click on a link, I want to be taken to that specific object's details. I can display a collection of item links on the index view, but when I click an item link, I can display the SingleProductView, but cannot display that specific item's variables there. Is it possible to pass the specific item to the view through the html.actionlink? Or, is it possible to pass that

AMF ActionResult for asp.net mvc

喜你入骨 提交于 2019-12-11 07:22:38
问题 I'm building a mvc application which will communicate with flash via AMF, anybody knows if there is any AMF ActionResult available on the web ? EDIT : using @mizi_sk answer (but without using IExternalizable) I did this ActionResult: public class AmfResult : ActionResult { private readonly object _o; public AmfResult(object o) { _o = o; } public override void ExecuteResult(ControllerContext context) { context.HttpContext.Response.ContentType = "application/x-amf"; using (var ms = new

LINQ left join only works in the ActionResult

谁说胖子不能爱 提交于 2019-12-11 05:14:28
问题 I'm trying to get up to speed with MVC, linq, razor, etc. Some things are working and others I just hit dead ends that really discourage me. This is the first one I haven't been able to work out. I've researched every lead I can before asking this question here and it's my first, so please go easy. I'm sure the answer is right in front of my face, but I just can't see it. I could type 14 pages of things I've tried, but I'm trying to keep this concise and to the point. I've completely mangled

Insufficient stack to continue executing the program safely. ASP.NET MVC 4

↘锁芯ラ 提交于 2019-12-08 16:53:41
问题 My search functionality seems to continue in a infinite loop, everytime my debug hits the action below the POST actionresult gets fired. In my Masterpage.cshtml I have following action: <li>@Html.Action("Search", "Search")</li> This is the part that gets the error of following: Insufficient stack to continue executing the program safely. This can happen from having too many functions on the call stack or function on the stack using too much stack space. In my SearchController I have one get

How to change the file name to be downloaded

。_饼干妹妹 提交于 2019-12-08 13:54:30
问题 Here is I have the result: <result name="success" type="stream"> <param name="contentDisposition">attachment;filename="${fileName}"</param> </result> How it works now: if my fileName is "raghu.txt" in DB it will be downloaded as raghu.txt What I want: regardless of fileName the output name should be ravi.txt . 回答1: Try in your action public String getFileName() { return "ravi.txt"; } When result is executed it will get the dynamic parameter via this method, and it will return the value wanted