I am working on a web app that is using AngularJS on the client side and in one of the forms I needed the user to be able to select time zones but I didn’t want to hard code it into the javascript, as well as it is getting stored on the back-end as my C# enum typeUSTimeZones
:public enum USTimeZones{AlaskanDaylightTime,AlaskanStandardTime,CentralDaylightTime,CentralStandardTime,EasternDaylightTime,EasternStandardTime,HawaiianStandardTime,MountainDaylightTime,MountainStandardTime,MountainTime,PacificDaylightTime,PacificStandardTime,USEasternStandardTime,USMountainStanardTime};[HttpGet]public IHttpActionResult GetTimeZonesJson(){var enumVals = new List<object>();foreach (var item in Enum.GetValues(typeof(USTimeZones))){enumVals.Add(new{id = (int)item,name = item.ToString()});}return Ok(enumVals);}
C# Enum Values as Json ASP.NET Web API Response
Search This Blog
Arsip Blog
Powered by Blogger.
Recent
Comment
Author Info
Like This Theme
Popular Posts
-
HTML -------------------------------------------------- < label class = "file-upload" > Browse < asp : FileUpload ...
-
1. Download and add FooTable js, css and image files in the project and reference in the page. 1 2 3 4 < meta ...
-
Create an MVC Web Application Open Visual Studio and create a new C# Web project named "ContosoUniversity". In the Ne...
-
SSL Certification creation ------------------------------------------------- Step1 : Download OpenSSL zip https://www.openssl.org/ St...
-
public class User { public int UserID { get ; set ; } [ Required ( ErrorMessage = "Please Enter Your Name" ...
-
public async Task < IHttpActionResult > GetItemsForFormType () { var result = new List < ItemManagementViewMode...
-
Optimizing for website performance includes setting long expiration dates on our static resources, such s images, stylesheets and JavaSc...
-
Update jquery.js file Every request checking to HTTP to https convertHttps : ((function() { if (window.location.href.toLo...
-
public static void MakeAccessible(GridView grid) { if (grid.Rows.Count <= 0) return; grid.UseAc...
-
<asp:Label ID="lblMessage" runat="server" Text="" ForeColor="Red"></asp:Label> ...
Video Of Day
jishnukanat@gmail.com
Sponsor
Most Popular
-
HTML -------------------------------------------------- < label class = "file-upload" > Browse < asp : FileUpload ...
-
1. Download and add FooTable js, css and image files in the project and reference in the page. 1 2 3 4 < meta ...
-
Create an MVC Web Application Open Visual Studio and create a new C# Web project named "ContosoUniversity". In the Ne...
-
SSL Certification creation ------------------------------------------------- Step1 : Download OpenSSL zip https://www.openssl.org/ St...
-
public class User { public int UserID { get ; set ; } [ Required ( ErrorMessage = "Please Enter Your Name" ...
-
public async Task < IHttpActionResult > GetItemsForFormType () { var result = new List < ItemManagementViewMode...
-
Optimizing for website performance includes setting long expiration dates on our static resources, such s images, stylesheets and JavaSc...
-
Update jquery.js file Every request checking to HTTP to https convertHttps : ((function() { if (window.location.href.toLo...
-
public static void MakeAccessible(GridView grid) { if (grid.Rows.Count <= 0) return; grid.UseAc...
-
<asp:Label ID="lblMessage" runat="server" Text="" ForeColor="Red"></asp:Label> ...