Posts

Showing posts with the label model-view-controller

Asp.net MVC5 - Object reference not set to an instance of an object.

Asp.net MVC5 - Object reference not set to an instance of an object. I'm training on Asp.net MVC5. and I did the follow. Model Name is Movie, with code as below., namespace mvc1.Models { public class Movie { public int Id { get; set; } public string Name { get; set; } } And a Controller with name 'MoviesConroller'. and a using statement "using mvc1.Models". public ActionResult Random() { var movie = new Movie() { Name = "Star Trek!" }; return View(); } And a View with name Random @model mvc1.Models.Movie @{ ViewBag.Title = "Random"; Layout = "~/Views/Shared/_Layout.cshtml"; } <h2>@Model.Name</h2> and this is the error i get Error By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the we...

MVC sql table data to html table

MVC sql table data to html table Hi guys i am new to mvc i am trying to get the sql table details to html table for that what i done is i have created a controller and model and view i also created sql table with fields of voucher number and amount. here is how i created the controller here i have referenced the model modeldemo <HttpGet> Function getVoucherDetails() As JsonResult Return Json(New ModelDemo().getVoucherDetails(), JsonRequestBehavior.AllowGet) End Function the model demo code consists of sql connection Public Function getVoucherDetails() As List(Of Hashtable) Dim listCharts As List(Of Hashtable) = New List(Of Hashtable) Dim arrayCharts As Hashtable Try Dim conn = New SqlConnection(connStringLocal) conn.Open() Using query = New SqlCommand("SELECT vchNum,totalAmount FROM BillHeader", conn) Using resultSet = query.ExecuteReader If resul...

How to block emoticons from input text field in codeignitier

How to block emoticons from input text field in codeignitier I want to make input text field in such a way that it will block emoticons entry in text input field. I have made validation on controller for particular route by passing.Is it is a right way to block emoticons. Controller code. $this->form_validation->set_rules('registration', 'Registration', 'required|alpha_numeric'); $this->form_validation->set_rules('odometer', 'Odometer', 'required|alpha_numeric'); view code: <input type="text" name="odometer" placeholder="Odometer" class="form-control profileControl odometer required number" id="odometer-<?php echo $vehicle_count; ?>" value="<?php echo $vehicle->intCarOdometer ?>"/> <input type="text" placeholder="Registration" name="registration" class="form-control profileControl registration req...