Submitting form and pass data to controller method of type FileStreamResult

When in doubt, follow MVC conventions. Create a viewModel if you haven’t already that contains a property for JobID public class Model { public string JobId {get; set;} public IEnumerable<MyCurrentModel> myCurrentModel { get; set; } //…any other properties you may need } Strongly type your view @model Fully.Qualified.Path.To.Model Add a hidden field for JobId to … Read more

Having troubles calling a Controller Post Method

I had a [lot] of trouble with this and I used this in the end; View: <% using (Html.BeginForm( “PhotoAdd”, “Photos”, FormMethod.Post, new { enctype = “multipart/form-data” })) { %> <input type=”file” id=”file” name=”file” class=”field” style=”width:300px;”/> <%} %> Controller: var file = Request.Files[“file”]; byte[] buf = new byte[file.ContentLength]; file.InputStream.Read(buf, 0, file.ContentLength); I’m not sure whether … Read more

How to return an object from a Spring MVC controller in response to AJAX request?

I need this list of employee in ajax In spring when you need object serialization, de-serialization and message conversion. in that case you need to annotate your controller handler method with @RequestBody and @ResponseBody. Where: @ResponseBody : will inform spring that try to convert its return value and write it to the http response automatically. … Read more

ASP.NET MVC Programmatically Get a List of Controllers

Using Jon’s suggestion of reflecting through the assembly, here is a snippet you may find useful: using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Web.Mvc; public class MvcHelper { private static List<Type> GetSubClasses<T>() { return Assembly.GetCallingAssembly().GetTypes().Where( type => type.IsSubclassOf(typeof(T))).ToList(); } public List<string> GetControllerNames() { List<string> controllerNames = new List<string>(); GetSubClasses<Controller>().ForEach( type => controllerNames.Add(type.Name)); return … Read more

How to pass parameters to a partial view in ASP.NET MVC?

Here is another way to do it if you want to use ViewData: @Html.Partial(“~/PathToYourView.cshtml”, null, new ViewDataDictionary { { “VariableName”, “some value” } }) And to retrieve the passed in values: @{ string valuePassedIn = this.ViewData.ContainsKey(“VariableName”) ? this.ViewData[“VariableName”].ToString() : string.Empty; }

Angular JS resizable div directive

This question is old, but for anybody looking for a solution, I built a simple directive to handle this, for vertical and horizontal resizers. Take a look at the Plunker angular.module(‘mc.resizer’, []).directive(‘resizer’, function($document) { return function($scope, $element, $attrs) { $element.on(‘mousedown’, function(event) { event.preventDefault(); $document.on(‘mousemove’, mousemove); $document.on(‘mouseup’, mouseup); }); function mousemove(event) { if ($attrs.resizer == ‘vertical’) … Read more

How to rename rails controller and model in a project

Here is what I would do: Create a migration to change the table name (database level). I assume your old table is called corps. The migration content will be: class RenameCorpsToStores < ActiveRecord::Migration def change rename_table :corps, :stores end end Change your model file name, your model class definition and the model associations: File rename: … Read more