controller

ASP.NET MVC download image rather than display in browser

让人想犯罪 __ 提交于 2019-12-28 11:44:01
问题 Rather than displaying a PNG in the browser window, I'd like the action result to trigger the file download dialogue box (you know the open, save as, etc). I can get this to work with the code below using an unknown content type, but the user then has to type in .png at the end of the file name. How can I accomplish this behavior without forcing the user to type in the file extension? public ActionResult DownloadAdTemplate(string pathCode) { var imgPath = Server.MapPath(service

Angularjs - Pass argument to directive

人盡茶涼 提交于 2019-12-28 04:59:06
问题 Im wondering if there is a way to pass an argument to a directive? What I want to do is append a directive from the controller like this: $scope.title = "title"; $scope.title2 = "title2"; angular.element(document.getElementById('wrapper')).append('<directive_name></directive_name>'); Is it possible to pass an argument at the same time so the content of my directive template could be linked to one scope or another? here is the directive: app.directive("directive_name", function(){ return {

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

怎甘沉沦 提交于 2019-12-28 02:03:51
问题 I have to return a list of employees from a controller in response to jQuery AJAX request. How should I do for it? My controller: @RequestMapping("phcheck") public ModelAndView pay(@RequestParam("empid") int empid, String fdate, String tdate) { ModelAndView mav = new ModelAndView("phcheck"); List<Employee> employees = entityManager.createQuery( "SELECT e FROM Employee e WHERE e.empId = " + empid, Employee.class) .getResultList(); mav.addObject("employees", employees); // I need this list of

I am trying to redirect to the show action(so I can see the new post) if a save is successful in the create action, but getting error?

十年热恋 提交于 2019-12-25 17:43:37
问题 I am trying to redirect to the show action after a successful create action in order to see the post the user just made (Post controller). I am getting this error message: syntax error, unexpected keyword_ensure, expecting end-of-input More debugging info: unless source.valid_encoding? raise WrongEncodingError.new(@source, Encoding.default_internal) end begin mod.module_eval(source, identifier, 0) ObjectSpace.define_finalizer(self, Finalizer[method_name, mod]) rescue => e # errors from

Why some model attributes not saved in the db?

99封情书 提交于 2019-12-25 16:54:27
问题 I have a Quote model in my rails app which has various attr types, some of which are being sent to / saved by the db, some are not and I cannot understand why. Please can you help me understand, thanks. quotes_controller.rb class QuotesController < ApplicationController def create @quote = Quote.new(quote_params) if @quote.save redirect_to root_url, notice: 'Quote request created' else render :new end end private def quote_params params.require(:quote).permit(:gla, :prev_cover, :co_name,

Bast Practise: ASP.NET MVC Controller/Action with multiple object types

浪尽此生 提交于 2019-12-25 16:26:15
问题 I'm looking for the best method for the following issue I have. I current have a large number of objects that all inherit for a single base object and are all very similar. Is there a solution available the will allow one create action and one edit action without needing to replicate a lot of the same code. So for example I might have a person object: public class PersonBase { public string FirstName { get; set; } public string LastName { get; set; } } And then I will have a number of objects

Bast Practise: ASP.NET MVC Controller/Action with multiple object types

*爱你&永不变心* 提交于 2019-12-25 16:26:10
问题 I'm looking for the best method for the following issue I have. I current have a large number of objects that all inherit for a single base object and are all very similar. Is there a solution available the will allow one create action and one edit action without needing to replicate a lot of the same code. So for example I might have a person object: public class PersonBase { public string FirstName { get; set; } public string LastName { get; set; } } And then I will have a number of objects

Silverstripe 3 - Unable to implement controller access security from CMS

﹥>﹥吖頭↗ 提交于 2019-12-25 15:17:09
问题 Good afternoon, I'm still new to silverstripe and I'm trying to figure out some really simple tasks. Currently, I'm trying to implement the security restrictions from my page controller function that was already created within my DataObject and configured via the CMS. However, whether or not I grant the user access to view the object, the user sees it anyhow. See example below: class MyComponent extends DataObject implements PermissionProvider{ ///>... this is just a snippet not the full

Silverstripe 3 - Unable to implement controller access security from CMS

…衆ロ難τιáo~ 提交于 2019-12-25 15:16:21
问题 Good afternoon, I'm still new to silverstripe and I'm trying to figure out some really simple tasks. Currently, I'm trying to implement the security restrictions from my page controller function that was already created within my DataObject and configured via the CMS. However, whether or not I grant the user access to view the object, the user sees it anyhow. See example below: class MyComponent extends DataObject implements PermissionProvider{ ///>... this is just a snippet not the full

Trouble using 'helper_method' and rendering templates

柔情痞子 提交于 2019-12-25 15:13:11
问题 I am using Ruby on Rails 3 and I am trying to set an helper_method that should work just for a controller (example: AccountsController) and for all views related to that, also when its views are rendered in another views not related to that controller. I take inspiration from the Railcast "Restricting Access". In my accounts_controller.rb file I have # Just to know, I am using a User namespace... class Users::AccountsController < ApplicationController helper_method :show_authorization def