Value cannot be null. Parameter name: items (DrodownList)

Consider the case when model validation fails. View will be redisplayed again with model sent with the request. However this line: new SelectList(ViewBag.Districts, “district_id”, “district_name”, Model.Districts) will have null as a first parameter, since ViewBag.Districts was not repopulated, causing the exception. So in order to avoid exception just set this property again: // If we … Read more

Spring Controller to handle all requests not matched by other Controllers

If your base url is like that= http://localhost/myapp/ where myapp is your context then myapp/a.html, myapp/b.html myapp/c.html will get mapped to the first 3 method in the following controller. But anything else will reach the last method which matches **. Please note that , if you put ** mapped method at the top of your … Read more

codeigniter check for user session in every controller

Another option is to create a base controller. Place the function in the base controller and then inherit from this. To achieve this in CodeIgniter, create a file called MY_Controller.php in the libraries folder of your application. class MY_Controller extends Controller { public function __construct() { parent::__construct(); } public function is_logged_in() { $user = $this->session->userdata(‘user_data’); … Read more

Angularjs: a Service that serves multiple $resource urls / data sources?

You can update service to return a hash of resources, not a single one: angular.module(‘myApp.services’, [‘ngResource’]). factory(“geoProvider”, function($resource) { return { states: $resource(‘../data/states.json’, {}, { query: { method: ‘GET’, params: {}, isArray: false } }), countries: $resource(‘../data/countries.json’, {}, { query: { method: ‘GET’, params: {}, isArray: false } }) }; }); You will be able … Read more

Call Controller Method Which Return View With Ajax Call From Asp.net View Page

If you wants to refresh page: Controller: public ActionResult Index() { return View(); } public ViewResult Test() { ViewBag.Name = Request[“txtName”]; return View(); } Index.cshtml: @using (Html.BeginForm(“Test”, “Home”, FormMethod.Post )) { <input type=”submit” id=”btnSearch” class=”btn btn-warning” style=”height:35px;width:120px” value=”Search”/> <label>Name:</label><input type=”text” id=”txtName” name=”txtName” /> } Test.cshtml: @ViewBag.Name ============================================= If you don’t wants to refresh page: Controller: … Read more

Spring forward with added parameters?

The simplest way is to add the data to the request. Since this is a forward, the same request is passed around to different handlers within the server. As example, let’s start with a simple setup of two controllers, one forwarding to the other: @Controller public class TestController { @RequestMapping(value=”/test”) public String showTestPage() { return … Read more