model-view-controller

MVC Validation with JQuery Accordion

谁说我不能喝 提交于 2020-01-05 08:25:06
问题 I am relatively new to ASP.NET MVC but am really impressed by the validation features. I have a giant form that I have split into an accordion using JQuery UI. This form is a very basic scaffold of a model and that model has code like the following to validate each field that is required: [Required(ErrorMessage="Please Enter a Valid Product")] [DisplayFormat(ConvertEmptyStringToNull= false)] [StringLength(160, MinimumLength=2,ErrorMessage="Product Must Be At Least 2 Characters")] and then the

Access properties in View phtml file that have been set in the Controller

落爺英雄遲暮 提交于 2020-01-05 07:30:10
问题 I am working on a small PHP website which is based on MVC. I have a front controller ( front.php ) which loads the controller ( services.php ), runs the action method ( hostingAction() ) and includes the html ( view.phtml ). There is a method call in view.phtml ( $this->renderContent() ) that includes the inner content ( hosting.phtml ). QUESTION: How can I set properties (e.g. $title = 'My Title'; ) in the hostingAction() method and then in view.phtml do <title><?php echo $title ?></title> ?

Regex is not working in RegularExpression attribute on c#

这一生的挚爱 提交于 2020-01-05 07:20:21
问题 guys, I don't know this question is already present or not but I have tried every search, so my question is why my regex is not working properly in RegularExpression attribute. this same regex I have used in javascript and this is working on javascript. can anyone help me what I am doing wrong here? [Required] [Display(Name = "First name")] [MaxLength(50)] [RegularExpression("^(?![@\\+\\-=\\*])", ErrorMessage = "First Name Should not start with these characters @, +, =, *, -")] public string

php website one page for design

心已入冬 提交于 2020-01-05 07:17:31
问题 I'm done creating a php website that has 6 pages, and the structure of the pages is the same for each one of them, the only thing that changes is the content, so is the same header, same design and same footer, the only thing that changes like I said before is the content itself. so i was thinking instead of having many pages, I could have only one design page, and change only the content, what do you recommend?,and how do I do that?, also im not planning installing anything like Typo3,

ASP.NET MVC Deleting row from one table after copying it to another table

冷暖自知 提交于 2020-01-05 05:46:10
问题 I have a case where I am trying to Delete one item from a table but before doing that I want to copy it to another table. Here is my Delete method: public ActionResult Delete(int id, Car car) { try { using (BookCarDBEntities db = new BookCarDBEntities()) { var carToDelete = db.Cars.FirstOrDefault(c => c.Id == id); var book = CreateNewBooking(carToDelete); db.Bookings.Add(book); db.Cars.Remove(carToDelete); db.SaveChanges(); return View(book); } catch (Exception ex) { return View(ex + "error")

Guidance trying to make skinny controllers & fat models in CakePHP

 ̄綄美尐妖づ 提交于 2020-01-05 05:25:28
问题 I'm new to Cake, and to MVC's in general. I want to establish good habits from the get go. Among the good habits are keeping controllers lean, and making the models fat. But it's a bit of a moving target for a noob like me. If I need to pass info from one model to another, do I just dump all that into the controller? Try to make it work in a model? Here's an action that is a prime example of the kind of confusion I'm trying to sort out. Everything seems like it should be in the controller,

KentorIT, SAML2, Okta, MVC Authentication - login issue

£可爱£侵袭症+ 提交于 2020-01-05 04:55:12
问题 I am a newbie, I have setup my MVC application that will use okta for Authentication, trying to achieve using KentorIT, when the user isn't logged-In it redirects to Okta, and but Okta sent the response back, I am getting null in loginInfo object always. public async Task<ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return RedirectToAction("Login"); } I have put my POC code at below

How do I display a record of database in asp.net mvc?

谁说我不能喝 提交于 2020-01-05 04:19:06
问题 I m working with asp.net with MVC code-first approaches. In my database, 4 records and I want to display record but a record not display? table name:empls How can I get records of database and display on the brows HomeController.cs public class HomeController : Controller { EmpContext contextemp = new EmpContext(); // GET: Home public ActionResult Index() { SqlConnection cn = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); String sql = "SELECT * FROM empls"

MVC implementation of Java Swing FocusListener

放肆的年华 提交于 2020-01-05 01:32:53
问题 I'm trying to build a simple Java Swing application using the MVC architecture pattern. What I've done is create the user interface components (as private) in my views, and have public methods that return the components. These methods are then called by the controllers, through which I can write methods for event/action listeners. Below is a sample example: View: private JButton btnAdd; public JButton getBtnAdd(){ return btnAdd; } Control: myGuiFrame gui = new myGuiFrame(); //on add button

How to break up an array into strings MVC?

雨燕双飞 提交于 2020-01-05 01:30:09
问题 If a current_user submits a habit, the days he :committed to doing it work like this: db t.text "committed", default: ["sun", "mon", "tue", "wed", "thu", "fri", "sat"], array: true habits/_form <%= f.collection_check_boxes :committed, Date::ABBR_DAYNAMES, :downcase, :to_s %> (user chooses days) habits_controller habit_params :committed => [] habits/index <% habit.committed.map { |d| d.titleize[0,3] }.each do |title| %> <%= title %> <% end %> If a nil user submits a habit (he is encouraged to