asp.net-mvc

KendoUI Grid Default Value with Data Annotation

故事扮演 提交于 2021-02-18 12:14:47
问题 I am using Kendo UI Grid with ASP.NET MVC Helpers and auto generated columns. I have [DefaultValue(60 * 60)] annotation in my view model but Kendo helpers doesn't seem to respect that. Can I have default value specified (probably with data annotations) without having to manually describe the columns? 回答1: if you defined the columns in the grid manually, you need to set the default value like this despite you defined the default value in the annotation or not @(Html.Kendo() .Grid() .DataSource

KendoUI Grid Default Value with Data Annotation

微笑、不失礼 提交于 2021-02-18 12:14:05
问题 I am using Kendo UI Grid with ASP.NET MVC Helpers and auto generated columns. I have [DefaultValue(60 * 60)] annotation in my view model but Kendo helpers doesn't seem to respect that. Can I have default value specified (probably with data annotations) without having to manually describe the columns? 回答1: if you defined the columns in the grid manually, you need to set the default value like this despite you defined the default value in the annotation or not @(Html.Kendo() .Grid() .DataSource

List of All Countries DropDown

大憨熊 提交于 2021-02-18 10:45:34
问题 I used this code to populate my dropdownlist with countries list: public JsonResult GetAllCountries() { var objDict = new Dictionary<string, string>(); foreach (var cultureInfo in CultureInfo.GetCultures(CultureTypes.SpecificCultures)) { var regionInfo = new RegionInfo(cultureInfo.Name); if (!objDict.ContainsKey(regionInfo.EnglishName)) { objDict.Add(cultureInfo.EnglishName, regionInfo.TwoLetterISORegionName.ToLower()); } } var obj = objDict.OrderBy(p => p.Key).ToArray(); return Json(obj

How to create MVC 4 @Html.TextBox type=“file”?

一世执手 提交于 2021-02-18 10:29:45
问题 I need to add the following field at my form <input type="file" class="input-file" /> I create model and describe this field (the last field) using System; using System.Collections.Generic; using System.Linq; using System.Web; namespace CorePartners_Site2.Models { public class FeedbackForm { public string Name { get; set; } public string Email { get; set; } public string Phone { get; set; } public string Company { get; set; } public string AdditionalInformation { get; set; } public

Optional Model Properties Binding in .NET Core MVC

六眼飞鱼酱① 提交于 2021-02-18 08:42:31
问题 I have created one AccountModel which has following properties public class AccountModel { [Required] [EmailAddress] public string Email { get; set; } [Required] [StringLength(10, MinimumLength = 6)] public string Password { get; set; } [NotMapped] // Does not effect with your database [Compare("Password")] [BindRequired] public string ConfirmPassword { get; set; } } I am trying to use same model for SignUp and SignIn . This model is perfectly working for signup but when I am using same model

Mapping to an ASMX service using routing in ASP.NET MVC

独自空忆成欢 提交于 2021-02-18 07:22:58
问题 I wonder if there's any way to map a URL to ASMX service much like it is done with pages (using routes.MapPageRoute() method). When I tried to do it simply by pointing the MapPageRoute to my service I get the error Type 'MvcApplication1.Services.EchoService' does not inherit from 'System.Web.UI.Page'. Matthias. 回答1: I stumbled upon this question trying to find the answer myself, and since I did figure out a way to do it, I figured I'd answer it. The reason I needed this is because I'm

Mapping to an ASMX service using routing in ASP.NET MVC

最后都变了- 提交于 2021-02-18 07:22:57
问题 I wonder if there's any way to map a URL to ASMX service much like it is done with pages (using routes.MapPageRoute() method). When I tried to do it simply by pointing the MapPageRoute to my service I get the error Type 'MvcApplication1.Services.EchoService' does not inherit from 'System.Web.UI.Page'. Matthias. 回答1: I stumbled upon this question trying to find the answer myself, and since I did figure out a way to do it, I figured I'd answer it. The reason I needed this is because I'm

Using ninject with Ninject.Web.Api for Web Api 2 is not working in ASP.NET MVC 5

℡╲_俬逩灬. 提交于 2021-02-18 07:06:20
问题 I am developing an Asp.NET MVC project. My project has web api as well. I am using ASP.NET MVC5 and Web Api 2 with Visual Studio 3. I am doing dependency injection using ninject. I know ninject for web is not working for Web Api 2. So I tried to use Ninject for Web Api. I installed ninject for web api 2 package using nuget package manager Then I installed Ninject.Web using nuget package manager Then in NinjectWebCommon, I added this line in RegisterServices private static void

Visual studio 2017 / 2019 add areas missing

佐手、 提交于 2021-02-18 05:01:05
问题 While creating a ASP.NET MVC Core Web app using VS2017 / 2019, came across that 'Add Areas' option is missing from Context menu. 回答1: Area is not removed from VS 2017/19 but it is moved in Scaffolding and you can access the area using below steps: 1) Right click on your project and click on Add>New Scaffolded Item 2) After click choose the MVC area from the Menu: 3) After choosing give it Name, and after this the Area will be added to your project: Hope it will helps. 回答2: I had a same

Visual studio 2017 / 2019 add areas missing

寵の児 提交于 2021-02-18 05:01:01
问题 While creating a ASP.NET MVC Core Web app using VS2017 / 2019, came across that 'Add Areas' option is missing from Context menu. 回答1: Area is not removed from VS 2017/19 but it is moved in Scaffolding and you can access the area using below steps: 1) Right click on your project and click on Add>New Scaffolded Item 2) After click choose the MVC area from the Menu: 3) After choosing give it Name, and after this the Area will be added to your project: Hope it will helps. 回答2: I had a same