Retrieving selected enum from dropdown list

I am binding an enumeration to a dropdown list in asp.net 4.0 C# Enumernation is: public enum Frequency { [Description("Select a frequency")] None, [Description("Every Hour/Mintues")] EveryHourOrMintues, [Description("Previous Day Data")] PreviousDayData, [Description("Once a week")] OnceaWeek } On the selection of a value from the dropdown I want to get th

从下拉列表中检索选定的枚举

我将一个枚举绑定到asp.net 4.0 C#中的下拉列表 使用是: public enum Frequency { [Description("Select a frequency")] None, [Description("Every Hour/Mintues")] EveryHourOrMintues, [Description("Previous Day Data")] PreviousDayData, [Description("Once a week")] OnceaWeek } 在从下拉列表中选择一个值时,我想要返回枚举值:我这样做: Frequency selectedFrequency; fo

ASP.NET MVC3: Object from DropdownList in Null in Controller

I have created a sample MVC3 application for BookShop. I have a create action. In the create action users enter name of a book, author name and select a genre name. It is working without errors. But in the controller, I am not getting the selected genre name ( - the genre object comes as null). How do we correct it? Note: When I write @Html.DropDownList("GenreId", String.Empty) t

ASP.NET MVC3:DropdownList中的对象在控制器中为空

我为BookShop创建了一个示例MVC3应用程序。 我有一个创建行动。 在创建操作中,用户输入书名,作者姓名并选择流派名称。 它工作没有错误。 但在控制器中,我没有得到所选的流派名称( - 流派对象为空)。 我们如何纠正它? 注意:当我编写@Html.DropDownList("GenreId", String.Empty) ,ASP.NET MVC中内置的模型绑定功能将尝试使用表单输入来填充该类型的对象。 例如,它会尝试设置书对象的GenreId值。 但Bo

Can you overload controller methods in ASP.NET MVC?

I'm curious to see if you can overload controller methods in ASP.NET MVC. Whenever I try, I get the error below. The two methods accept different arguments. Is this something that cannot be done? The current request for action 'MyMethod' on controller type 'MyController' is ambiguous between the following action methods: You can use the attribute if you want your code t

你可以在ASP.NET MVC中重载控制器方法吗?

我很好奇你是否可以在ASP.NET MVC中重载控制器方法。 每当我尝试,我都会得到下面的错误。 这两种方法接受不同的论点。 这是不能做到的吗? 当前在控制器类型“MyController”上的操作“MyMethod”请求在以下操作方法之间不明确: 如果你想让代码重载,你可以使用这个属性。 [ActionName("MyOverloadedName")] 但是,你必须为同一个http方法使用不同的动作名称(正如其他人所说的那样)。 所以这只是语义。 你想在你的代

How to determine the represented type of enum value?

Consider the following two enums: enum MyEnum1 { Value1 = 1, Value2 = 2, Value3 = 3 } enum MyEnum2 { Value1 = 'a', Value2 = 'b', Value3 = 'c' } I can retrieve the physical value represented by these enum values through explicit casting, ((int)MyEnum1.Value2) == 2 or ((char)MyEnum2.Value2) == 'b' , but what if I want to get the char representation or the int r

如何确定表示类型的枚举值?

考虑以下两个枚举: enum MyEnum1 { Value1 = 1, Value2 = 2, Value3 = 3 } enum MyEnum2 { Value1 = 'a', Value2 = 'b', Value3 = 'c' } 我可以通过显式转换, ((int)MyEnum1.Value2) == 2或((char)MyEnum2.Value2) == 'b'检索由这些枚举值表示的物理值,但是如果我想获取char表达式还是int表示,而不先知道要转换的类型? 是否有可能在没有转换的情况下获得枚举的基础值,或者是否至

Is there a conventional way of returning error statuses from JSON web services?

I have a .NET .ashx handler, which receives a jQuery AJAX post, formats a web service request to a third-party service and consumes the result. On success, it instantiates an anonymous object with the relevant information and formats a JSON response string. In the event of a web service error, I do the following: context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.R

有没有从JSON Web服务返回错误状态的传统方式?

我有一个.NET .ashx处理程序,它接收一个jQuery AJAX帖子,将一个Web服务请求格式化为第三方服务并使用结果。 成功时,它会使用相关信息实例化一个匿名对象并格式化JSON响应字符串。 在发生Web服务错误时,我会执行以下操作: context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; context.Response.StatusDescription = wsResult.ErrorCode; 这使得状态代码和描述都可以通过jQuery AJAX错误回调轻松访

Oauth refresh token provider error in ValidateClientAuthentication

I apologize for my English. I presented the following problem. I'm working with C # asp.net MVC 5. I am implementing a server with the OAuth 2 bearer token and token refresh. When requesting the access token returns me refresh token and token with client_credential grant_type, client_id and client_secret. The problem is to apply the new refresh token from token. When I shipping grant_t

Oauth在ValidateClientAuthentication中刷新令牌提供程序错误

我为我的英语道歉。 我提出了以下问题。 我正在使用C#asp.net MVC 5。 我正在使用OAuth 2载体令牌和令牌刷新来实现服务器。 请求访问令牌时,会返回刷新令牌和具有client_credential grant_type,client_id和client_secret的令牌。 问题是从令牌应用新的刷新令牌。 当我运送grant_type refresh_token和refresh_token参数作为第一种方法时,称为ValidateClientAuthentication。 但作为shipping和client_secret client_id

Web api bearer token timeout some minutes later

I am using asp.net web api and token based authentication. My token options is set success token expire time to 14 days later. OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new SimpleAuthorizationServerProvider(), AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), AccessTokenExpireTimeSpan = TimeS

几分钟后Web api持票人令牌超时

我正在使用asp.net web api和基于令牌的身份验证。 我的令牌选项设置成功令牌过期时间为14天以后。 OAuthOptions = new OAuthAuthorizationServerOptions { TokenEndpointPath = new PathString("/Token"), Provider = new SimpleAuthorizationServerProvider(), AuthorizeEndpointPath = new PathString("/api/Account/ExternalLogin"), AccessTokenExpireTimeSpan = TimeSpan.FromDays(14), // In produc

Loading large data in jquery

I have a web service that returns data, quite a large set, could be 600 rows, by 20 columns. What is the fastest most efficient way to load this data into an html table in Jquery code? I tried creating the table html by looping through the data returned and creating a table DOM inside a string, but the looping part is very slow. I have heard of Jquery Templates, but I am not sure this technol

在jquery中加载大量数据

我有一个Web服务返回数据,相当大的一组,可能是600行,20列。 在Jquery代码中将这些数据加载到html表中的最快最有效的方法是什么? 我尝试通过循环返回的数据来创建表格html,并在字符串内创建表格DOM,但循环部分非常缓慢。 我听说过Jquery Templates,但我不确定这项技术对于大型数据集足够快。 谢谢 是否有可能改变Web服务或让另一个服务调用它并解析数据服务器端并返回HTML? 在客户端处理JSON将成为您的瓶颈。

When should I use JSON serialization and why?

I am a little confused about when do I have to serialize objects using JSON serialization and when it is not necessary (even needless). I've spent several days trying to send a list of simple objects using jQuery.ajax and JSON. I have a class named Product: public class Product { public string Name; public string Qnt; public string Price; } and a web method that returns a lis

我应该何时使用JSON序列化,为什么?

我有点困惑,我何时必须使用JSON序列化序列化对象,何时不需要(甚至是不必要的)。 我花了几天的时间尝试使用jQuery.ajax和JSON发送简单对象列表。 我有一个名为Product的类: public class Product { public string Name; public string Qnt; public string Price; } 以及一个返回填充产品列表的Web方法 List<Product> p = new List<Product>(); 我用System.Web.Script.Serialization.JavaScri

ASP.NET Web API Return JSON as an object

Currently the Web API which queries the Oracle DB is returning the result in the JSON in the below format. [{"CATEGORY":"Internal Study","SESSION_NUMBER":7,"SESSION_START_DATE":"2015-02-13T00:00:00","SESSION_START_TIME":"2015-02-13T10:33:59.288394"}] Below is the code we are using public class SampleController : ApiController { public HttpResponseMessage Getdetails([FromUri] string[] id)

ASP.NET Web API将JSON作为对象返回

目前,查询Oracle数据库的Web API以下面的格式返回JSON中的结果。 [{"CATEGORY":"Internal Study","SESSION_NUMBER":7,"SESSION_START_DATE":"2015-02-13T00:00:00","SESSION_START_TIME":"2015-02-13T10:33:59.288394"}] 以下是我们正在使用的代码 public class SampleController : ApiController { public HttpResponseMessage Getdetails([FromUri] string[] id) { using (OracleConnection dbconn = new OracleC