controller

How to post the selected value of a selectlist to the controller using a view model?

时光毁灭记忆、已成空白 提交于 2019-12-08 05:27:06
问题 This question has been asked in various forms but none of the answers seem to fit my situation. I am simply trying to retrieve the selected value of a dropdown list in my controller. Here is my code: ViewModel.cs public class ViewModel { public ViewModel() {} public ViewModel(Contact contact, IEnumerable<State> states) { this.Contact = contact; this.States = new SelectList(states, "Id", "Name", contact.StateId); } public Contact Contact {get;set;} public SelectList States {get;set;} }

generate dropdownlist from a table in database

醉酒当歌 提交于 2019-12-08 04:53:17
问题 I'm tryng to be more precise to my previous question which can be found here, I got some nice answers but couldn't figure out how to use it in my situation Previous question I got some nice answers but couldn't figure out how to use it in my situation. basically I want to have registration page which contains Email //Comes from my AspNetUser(datamodel) class, also AspNetUsers table exists in database. UserName //Comes from my AspNetUser(datamodel) class, also AspNetUsers table exists in

cakephp requestAction method View file

这一生的挚爱 提交于 2019-12-08 04:50:36
问题 How can i call a requestAction method from my view , to specific controller , which returns me results on basis of conditions i mention? Thanks ! 回答1: Generally speaking, using requestAction is not very performant, because it begins a whole new dispatch process -- in essence your application is handling two requests for every one request made by a user. For this reason, you want to avoid using it as much as possible. That being said, requestAction has its uses, and you can mitigate the

Checking session exists or not- mvc3

孤人 提交于 2019-12-08 04:13:32
问题 I was googling on Sessions and mvc3, and I found this link. To that question a marc-gravell answered The session only really exists during the processing of an action - I wouldn't expect it to be valid in the constructor of a controller. For example, the controller might (for all I know) be re-used between requests. I think that may not be the case by reading further on mvc requests and creation of controller, I found this: A Controller is created for every request by the ControllerFactory

C++ sending Joystick directional input to program

左心房为你撑大大i 提交于 2019-12-08 03:56:46
问题 I'm trying to spoof a PS3 controller and send analog stick directional input to a specific program, but i can't figure out how the INPUT.hi struct works. I can send keypresses over with INPUT keys; keys.type = INPUT_KEYBOARD; keys.ki.dwFlags = KEYEVENTF_SCANCODE; keys.ki.wScan = 0x11;//hex for 'w' key SendInput(1, &keys, sizeof(INPUT)); Sleep(60);//delay to ensure game doesnt drop keypress keys.ki.dwFlags = KEYEVENTF_SCANCODE | KEYEVENTF_KEYUP; SendInput(1, &keys, sizeof(INPUT)); and i

Multi-level controllers for MVC architecture

限于喜欢 提交于 2019-12-08 03:34:36
问题 I just encountered one of the limitations of the MVC architecture I'm currently using for my applications. Currently, my URLs look like this: www.example.com/controller/action Each request arrives at the front controller, which loads the requested controller class from the URL, and executes the action (method) of it. This works fine, until you need to start using nested controllers. Example: There's a 'users' controller which holds methods like createUser(), editUser(), deleteUser() etc. All

php session flash message

北战南征 提交于 2019-12-08 02:56:09
问题 i'm tryning to create session flash message after redirection. i have Controller class class Controller { function __construct() { if(!empty($_SESSION['FLASH'])) foreach($_SESSION['FLASH'] as $key => $val) $this->$key = $val; } function __destruct() { $_SESSION['FLASH']=null; } } also i have Controller child class Home, where functions are run by route, like /Home/Index => public function index() class Home extends Controller { function __construct() { parent::__construct(); } public function

How to perform Controller.destroy action asynchronously in rails?

北城以北 提交于 2019-12-08 02:54:09
问题 I can easily delete the entries of post synchronously in rails application by following code: views <% @post.each do |post| %> <tr> <td colspan="3"><%= link_to 'Destroy', post, :method => :delete, :confirm => 'Are you sure?', :class => 'btn btn-mini btn-danger' %></td> </tr> <% end %> Controller class def destroy @post = Post.find(params[:id]) @post.destroy respond_to do |format| format.html redirect_to(posts_url) } format.xml { head :ok } end end This works fine. How make this destroy

Passing the same data over different views in Laravel

对着背影说爱祢 提交于 2019-12-08 02:20:27
问题 I have for example this code in my HomeController: public function index() { $comments = Comment::get_recent(); $top = User::get_top_uploaders()->get(); $top_something = User::get_top_something_uploaders()->get(); $data = Post::orderBy('created_at', 'DESC')->paginate(6); return View::make('index') ->with('data', $data) ->with('comments', $comments) ->with('top', $top) ->with('top_something', $top_something); } It works great, but I need to make another couple of view with the same data not

Grails controller unit tests with Joda Time

别来无恙 提交于 2019-12-08 01:59:29
问题 Some of the controller tests that generate-all creates are failing when I have a domain object with a Joda LocalDateTime field. $ grails create-app bugdemo $ cd bugdemo $ grails create-domain-class Item Edit grails-app/domain/bugdemo/Item.groovy package bugdemo import org.joda.time.LocalDateTime class Item { String name // LocalDateTime opening static constraints = { name blank:false } } Add the following line to BuildConfig.groovy compile ":joda-time:1.4" Continue at the command line $