razor

Getting a null exception as model in razor

こ雲淡風輕ζ 提交于 2020-01-06 14:52:07
问题 I have an error's view in my asp.net mvc4 application like this: @model System.Web.Mvc.HandleErrorInfo @{ ViewBag.Title = "Erreur"; } <p>Take it easy</p> <hgroup class="title"> <h1 class="error">Erreur = @Model.Exception</h1> <h1 class="error">Controller = @Model.ControllerName</h1> <h1 class="error">Name = @Model.ActionName</h1> <h2 class="error">Une erreur s'est produite lors du traitement de la requête.</h2> </hgroup> The controller code : public class HomeController : Controller {

How to hide one field when the user enter data in another field .NET MVC 4 Razor

旧街凉风 提交于 2020-01-06 13:57:27
问题 I had one field something like Holiday such that is given below, [StringLength(50)] [DisplayName(Constants.DisplayName.HolidayDay)] public virtual string HolidayDay { get; set; } And public virtual enumHolidayDay enumHolidayDay { get { return (enumHolidayDay)Enum.Parse(typeof(enumHolidayDay), HolidayDay); } set { HolidayDay = value.ToString(); } } And public enum enumHolidayDay { [Description("Saturday")] saturday = 1, [Description("Sunday")] sunday = 2, } And my Holiday.cshtml file is

Pass data to view using action C# MVC

随声附和 提交于 2020-01-06 13:53:10
问题 I'm currently working on a project in which we have a number of similar models. We made them all inherit from the same base model and we also made a common controller (basic stuff like list, adding, editing etc.) handles the base model. It actually works and made things easy for us, but I have small problem with dropdowns. Without going into much details, it would make things really easy for me if I could pass data from controller to view using an action. Something like this: @Html

EF7 nested Include not showing in Razor .net

大兔子大兔子 提交于 2020-01-06 13:11:34
问题 I have my models like this: Goup.cs GroupUser (pivot table) ApplicationUser (User) -> 4. Profile And now I want to show the data in Profile on a details page when the User belongs to the group. I'm doing this like this: private IEnumerable<GroupUser> GetUsers(int groupId) { IEnumerable<GroupUser> model = null; if(groupId == 0) { model = _kletsContext.GroupUser.OrderByDescending(o => o.GroupId).AsEnumerable(); } else { model = _kletsContext.GroupUser.Where(g => g.GroupId == groupId).Include(p

EF7 nested Include not showing in Razor .net

不羁岁月 提交于 2020-01-06 13:10:43
问题 I have my models like this: Goup.cs GroupUser (pivot table) ApplicationUser (User) -> 4. Profile And now I want to show the data in Profile on a details page when the User belongs to the group. I'm doing this like this: private IEnumerable<GroupUser> GetUsers(int groupId) { IEnumerable<GroupUser> model = null; if(groupId == 0) { model = _kletsContext.GroupUser.OrderByDescending(o => o.GroupId).AsEnumerable(); } else { model = _kletsContext.GroupUser.Where(g => g.GroupId == groupId).Include(p

Using Razor to create a form for hierarchy of domain models

那年仲夏 提交于 2020-01-06 10:40:53
问题 Lets say I have the following classes (could you also consider if my classes in terms of that relation part is correct): public class EFDbContext : DbContext { public DbSet<Project> Projects { get; set; } public DbSet<Address> Addresses { get; set; } // * public DbSet<Country> Countries { get; set; } // * // Custom model builder bindings for * coz of the plural issue with EF } public class Project { public int ProjectID { get; set; } public string Name { get ; set; } public int AddressID {

Using Razor to create a form for hierarchy of domain models

…衆ロ難τιáo~ 提交于 2020-01-06 10:39:27
问题 Lets say I have the following classes (could you also consider if my classes in terms of that relation part is correct): public class EFDbContext : DbContext { public DbSet<Project> Projects { get; set; } public DbSet<Address> Addresses { get; set; } // * public DbSet<Country> Countries { get; set; } // * // Custom model builder bindings for * coz of the plural issue with EF } public class Project { public int ProjectID { get; set; } public string Name { get ; set; } public int AddressID {

Ado.net EDMX model table fields custom validation

▼魔方 西西 提交于 2020-01-06 10:34:26
问题 I have generated the data table model using the option "Generate model from database" in the entity framework and now the model contains the IDE generated code of the models. The models are working fine and now I have a problem, because I want to add custom validations to the table fields and the error messages & the field names should be taken from the resource file. The validation should be done in the ajax call. Can anyone help me to add these validations to the automatically generated

Ado.net EDMX model table fields custom validation

给你一囗甜甜゛ 提交于 2020-01-06 10:33:37
问题 I have generated the data table model using the option "Generate model from database" in the entity framework and now the model contains the IDE generated code of the models. The models are working fine and now I have a problem, because I want to add custom validations to the table fields and the error messages & the field names should be taken from the resource file. The validation should be done in the ajax call. Can anyone help me to add these validations to the automatically generated

Ado.net EDMX model table fields custom validation

冷暖自知 提交于 2020-01-06 10:32:32
问题 I have generated the data table model using the option "Generate model from database" in the entity framework and now the model contains the IDE generated code of the models. The models are working fine and now I have a problem, because I want to add custom validations to the table fields and the error messages & the field names should be taken from the resource file. The validation should be done in the ajax call. Can anyone help me to add these validations to the automatically generated