asp.net-mvc-viewmodel

Client form validation not working with modal dialog in MVC

北慕城南 提交于 2019-12-20 09:47:11
问题 I am changing a create form to become a modal dialog and jquery Unobtrusive validation stops working and don't know how to fix it. Index.cshtml has a link to trigger a modal dialog. <a href="#" id="createCustomer">Create</a> @section scripts{ <script type="text/javascript"> $('#createCustomer').on('click', function () { $.get('/Customer/Create', function (data) { $('#modalContainer').html(data); $('#myModal').modal({}); }); }); Create.cshtml is a partial view. @model Demo.Web.Models

ViewBag vs Model, in MVC.NET [closed]

[亡魂溺海] 提交于 2019-12-17 19:37:53
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . This is more of a generic architectural question: I'm trying to decide if it's ok for my programmers to use "ViewBags" to pass data to views that already accept Models. My personal preference is to avoid ViewBags and build Robust Models containing all the data the view

How to use ViewModels in ASP.NET MVC?

我是研究僧i 提交于 2019-12-17 18:58:03
问题 I just started learning about ViewModels in ASP.NET MVC. So, I thought of implementing a sample example as below: Business Entity public class AddModel { public int a { get; set; } public int b { get; set; } public int Add() { return (this.a + this.b); } } Add ViewModel public class AddViewModel { public AddModel addModel; public int Total { get; set; } } Controller public class AddController : Controller { [HttpPost] public JsonResult Add(AddViewModel model) { int iSum = model.addModel.a +

How to use ViewModels in ASP.NET MVC?

守給你的承諾、 提交于 2019-12-17 18:57:10
问题 I just started learning about ViewModels in ASP.NET MVC. So, I thought of implementing a sample example as below: Business Entity public class AddModel { public int a { get; set; } public int b { get; set; } public int Add() { return (this.a + this.b); } } Add ViewModel public class AddViewModel { public AddModel addModel; public int Total { get; set; } } Controller public class AddController : Controller { [HttpPost] public JsonResult Add(AddViewModel model) { int iSum = model.addModel.a +

MVC ViewModel example

大兔子大兔子 提交于 2019-12-17 15:40:08
问题 I've been doing tutorials and trying to learn best practice when it comes to MVC development. The design I'm using below comes from Pro ASP.Net MVC5 by Apress/Adam Freeman. So far, everything is coming along good...but I still have not completely come to grip on working with Controllers. Yes, I understand the concept of Controllers, but still struggle when it comes to post and get methods. Here is the flow of my sample MVC application: My app.Domain project I have a user table in the database

required attribute not working in asp.net mvc

我只是一个虾纸丫 提交于 2019-12-17 13:41:14
问题 I have a simple strongly-typed view. @model GoldForGold.Models.LogonModel @{ ViewBag.Title = "Logins"; Layout = "~/Views/Shared/_Layout.cshtml"; } Logins @using (Html.BeginForm()) { Account Information @Html.LabelFor(m => m.UserName) @Html.TextBoxFor(m => m.UserName, new { id = "txtUserName" }) @Html.ValidationMessageFor(m => m.UserName) @Html.LabelFor(m => m.Password) @Html.PasswordFor(m => m.Password, new { id = "txtPassword" }) @Html.ValidationMessageFor(m => m.Password) @Html.CheckBoxFor

Is it possible to create view models by out of models created from database tables using entity framework DB first approach?

空扰寡人 提交于 2019-12-13 03:55:53
问题 Since I have started using DATABASE FIRST approach of entity framework. It's easy to catch on and interesting but there's one thing that puzzles me. In MVC we usually make view models (models with plus-minus properties so it adheres to the particular view). Fine but while using the EF with DB first approach this seems to be impossible. Because we create one model off a database table and then keeps on using it for insert, update, select or anything. e.g. Services model: namespace ZahidCarWash

Form with Two Columns

纵饮孤独 提交于 2019-12-13 03:00:58
问题 Hello as the title states I would like to create a form with 2 columns. In the end I want it to look like this jsfiddle I've been playing with. however by looking at the code I don't believe this is the proper way, correct me if I'm wrong. The code is a standard MVC ViewModel that creates an entry into a database. here is the code I currently have in jsfiddle: HTML <label for="IDofInput">text goes here</label> <label for="IDofInput">text goes here</label> <br /> <input type="text" id=

EmailAttribute is not validating correctly in a ViewModel from ASP.NET Core

守給你的承諾、 提交于 2019-12-12 11:05:39
问题 This is a field located in my viewmodel: [Required(ErrorMessage = "Email is missing."), EmailAddress(ErrorMessage = "Email is not valid.")] public string Email { get; set; } ( EmailAddress is from the EmailAddressAttribute.EmailAddressAttribute() type) This is the relevant part from the HTML: <div> <label for="inputEmail">EMAIL</label> <input id="inputEmail" ng-model="email" asp-for="Email" class="form-control" /> </div> <div> <span asp-validation-for="Email" class="text-danger"></span> </div

Resuse ViewModel in Asp.net MVC

倖福魔咒の 提交于 2019-12-11 03:18:00
问题 I have seen lots of blog about MVVM vs MVC and blogs that says thay MVVM is like MVC extension in Windows. I have one design issue, I have made one win application that uses MVVM , now i have to create a same application in Web, so i decided to MVC pattern in Asp.net, but now again i am stuck at point. how to reuse ViewModels in MVC? because ViewModel has imports namespace System.Windows.Input. Is there any alternative soultions?? My primary requirement is reusing application logic? I have