asp.net-mvc

Validate String Array In ASP.NET MVC in client side

白昼怎懂夜的黑 提交于 2021-02-20 05:09:15
问题 This is my first post. I need string array validation such like below. [Required(ErrorMessage = "Content name is required")] public string[] ContentName { get; set; } I found a post which has the same situation. This answer and following code helped me so much and I could solve my problem. public class StringArrayRequiredAttribute : ValidationAttribute { protected override ValidationResult IsValid (object value, ValidationContext validationContext) { string[] array = value as string[]; if

Validate String Array In ASP.NET MVC in client side

[亡魂溺海] 提交于 2021-02-20 05:08:57
问题 This is my first post. I need string array validation such like below. [Required(ErrorMessage = "Content name is required")] public string[] ContentName { get; set; } I found a post which has the same situation. This answer and following code helped me so much and I could solve my problem. public class StringArrayRequiredAttribute : ValidationAttribute { protected override ValidationResult IsValid (object value, ValidationContext validationContext) { string[] array = value as string[]; if

Entity Framework and ASP.NET MVC 5 How can I push selected checkoxes into my localDB?

一曲冷凌霜 提交于 2021-02-20 04:45:25
问题 I am having troubles with pushing selected checkboxes into the table. I have three tables - Employees , Projects and EmployeeProject . For one Employee I want to be able to choose multiple projects. I already created a create view with inputs for name of the employee and checkboxes of the projects. How can I send data to the EmployeeProjects table? So I could display it later. My models: public class Employee { [Key] public int Id { get; set; } public string FirstName { get; set; } public

Entity Framework and ASP.NET MVC 5 How can I push selected checkoxes into my localDB?

只愿长相守 提交于 2021-02-20 04:45:06
问题 I am having troubles with pushing selected checkboxes into the table. I have three tables - Employees , Projects and EmployeeProject . For one Employee I want to be able to choose multiple projects. I already created a create view with inputs for name of the employee and checkboxes of the projects. How can I send data to the EmployeeProjects table? So I could display it later. My models: public class Employee { [Key] public int Id { get; set; } public string FirstName { get; set; } public

Validation error about Decimal data type in asp.net mvc

心已入冬 提交于 2021-02-20 04:26:12
问题 I defined a data type decimal(18,10) for longitute and latitute in my database. But it always said "validation error" when I tried to input and submit my form. I used LINQ to SQL . Is there some validation rules it generated for me otherwise why I can not input these two with something numbers like "2.34". Thanks in advance namespace Nerddinner.Models { interface IDinnerRepository { IQueryable<Dinner> FindAllDinners(); Dinner GetDinner(int id); void AddDinner(Dinner dinner); void UpdateDinner

Implementing role based authorization in MVC and Web API with custom table

纵饮孤独 提交于 2021-02-20 04:21:05
问题 I have inherited an application with database. The database has following tables related to authentication and authorization. User Table UserName Password UserTypeId UserType Table UserTypeId UserTypeDesc The User Type table stores the roles for the user e.g. Admin, Editor, etc. If I want to implement authorization like below [Authorize(Roles="Admin, Editor")] public IHttpActionResult GetOrders() { //Code here } Where and what should I code so that the roles are available to the authorize

ASP.NET MVC Pagination Not Working on ViewModel

不羁的心 提交于 2021-02-20 02:50:07
问题 I am using pagination in my project. I have search box and sending searching text to Action Result. I hitted break point to Search ActionResult. My news and announcements are filling after select queries. Search ActionResult public ActionResult Search(string searchText,int? page) { int pageIndex=page??1; int dataCount=20; dbContext=new dbContext(); SearchViewModel searchViewModel=new SearchViewModel(); var news=(from news in dbContext.News where news.Title.Contains(searchText) select news)

A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' was not present on the provided ClaimsIdentity

╄→гoц情女王★ 提交于 2021-02-20 00:29:57
问题 i using claim in login . but it show me this error A claim of type http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier was not present on the provided ClaimsIdentity. how solve this ? public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); /

A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' was not present on the provided ClaimsIdentity

為{幸葍}努か 提交于 2021-02-20 00:25:34
问题 i using claim in login . but it show me this error A claim of type http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier was not present on the provided ClaimsIdentity. how solve this ? public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); /

A claim of type 'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier' was not present on the provided ClaimsIdentity

▼魔方 西西 提交于 2021-02-20 00:24:38
问题 i using claim in login . but it show me this error A claim of type http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier was not present on the provided ClaimsIdentity. how solve this ? public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); /