Exemplo n.º 1
0
        public ActionResult UsingDisplayAttribute()
        {
            JscriptViewModel model = new JscriptViewModel();

            //great time to use the var keyword as it allows us to collect as many enums as we need
            var enumList = new
            {
                //Look at how the different Methods output the JS objects
                HttpStatusCodes = typeof(System.Net.HttpStatusCode).EnumByDisplay(1)
                ,
                CommandBehaviors = typeof(System.Net.HttpStatusCode).EnumByName(1)
            };

            Response.ContentType = "application/javascript";
            model.Name           = String.Format(KIND_FORMAT, "Example"); //"ExampleNameKinds";
            model.Kinds          = enumList;
            return(View("Dynamic", model));
        }
Exemplo n.º 2
0
        public ActionResult Simple(string view)
        {
            JscriptViewModel model = new JscriptViewModel();

            //great time to use the var keyword as it allows us to collect as many enums as we need
            var enumList = new
            {
                //Look at how the different Methods output the JS objects
                HttpStatusCodes = System.Net.HttpStatusCode.Accepted.ToDictionaryByValue()
                ,
                CommandBehaviors = System.Data.CommandBehavior.CloseConnection.ToDictionaryByValue()
            };

            Response.ContentType = "application/javascript";

            model.Name  = String.Format(KIND_FORMAT, "Example"); //"ExampleNameKinds";
            model.Kinds = enumList;

            return(View(view, model));
        }