当前位置: 首页>>代码示例>>C#>>正文


C# FormCollection.GetValues方法代码示例

本文整理汇总了C#中System.Web.Mvc.FormCollection.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# FormCollection.GetValues方法的具体用法?C# FormCollection.GetValues怎么用?C# FormCollection.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.FormCollection的用法示例。


在下文中一共展示了FormCollection.GetValues方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Ajouter

        public ActionResult Ajouter(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                bool isSith;

                if (collection.GetValues("IsSith").First() == "true")
                {
                    isSith = true;
                }
                else isSith = false;

                /*ViewBag.caracForce = client.GetCaracteristiques().Where(c => c.Nom == collection.GetValues("Force").First());
                Console.WriteLine(client.GetCaracteristiques().Where(c => c.Nom == collection.GetValues("Force").First()));*/
                /*if (Request.Form["force"] != null)
                {
                    Console.WriteLine("HAHAHAHAHAHAHAHAH" + Request.Form["force"]);
                }
                else Console.WriteLine("KOUKOU");*/

                /*ViewBag.test = client.GetCaracteristiques().Where(c => c.Nom == Request.Form["force"]);*/

                client.AddJedi(collection.GetValues("Nom").First(), isSith, null, null,null,null);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:bahumbert,项目名称:JediTournament,代码行数:33,代码来源:JediController.cs

示例2: LoGon2

        public ActionResult LoGon2(FormCollection forms)
        {
            string username = forms.GetValues("navbar_username")[0];
            string password = forms.GetValues("navbar_password")[0];
            bool remember = bool.Parse(forms.GetValues("navbar_remeber")[0]);
            string url = forms.GetValues("navbar_url")[0];

            if (MembershipService.ValidateUser(username, password))
            {
                FormsService.SignIn(username, remember);
                if (!String.IsNullOrEmpty(url))
                {
                    return Redirect(url);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }

            return Redirect(url);
        }
开发者ID:hikaruyh88,项目名称:ProjectAnalyzeV3.0,代码行数:26,代码来源:AccountController.cs

示例3: getDeclareInfo

        public ActionResult getDeclareInfo(FormCollection collect)
        {
            Model.declareViewModel d_project = new Model.declareViewModel();
            d_project.project_name=Request["project_name"];
            d_project.declarant_id = (string)SessionHelper.Get("ID");
               // d_project.declarant_id = (string)Session["ID"];
            d_project.phone = Request["mainer_phone"];
            d_project.email=Request["mainer_email"];
            d_project.leader=Request["mainer_name"];
            d_project.p_type=Request["p_type"];
            d_project.now_level=Request["now_level"];
            d_project.target_level=Request["target_level"];
            d_project.s_time=Convert.ToDateTime(Request["s_time"]);
            d_project.f_time = Convert.ToDateTime(Request["f_time"]);
            d_project.money = Convert.ToInt16(Request["money"]);
            d_project.p_id = BLL.ProjectServer.getProjectNum() + 1;
            d_project.create_time = DateTime.Now;
            //d_project.belongs=(string)Session["belongs"];
            d_project.belongs = SessionHelper.Get("p_belongs");
            string[] ts_time = collect.GetValues("ts_time");
            string[] tf_time = collect.GetValues("tf_time");
            string[] t_content = collect.GetValues("t_content");
            string[] member2 = collect.GetValues("member");
              d_project.member = new List<Member>();
            foreach (string m in member2)
            {

                Model.Member mem=new Model.Member();
                mem.nickname = m;
                mem.project_id = BLL.ProjectServer.getProjectNum()+1;
                d_project.member.Add(mem);
            }
              d_project.task = new List<Task>();
            for(int i=1;i<=ts_time.Count();i++){

                Task t = new Task();
                t.t_id = i;
                t.s_time=Convert.ToDateTime(ts_time[i-1]);
                t.f_time=Convert.ToDateTime(tf_time[i-1]);
                t.task_content=t_content[i-1];
                d_project.task.Add(t);

            }

            HttpPostedFileBase paper_file=Request.Files["paper_file"];
            HttpPostedFileBase report_file = Request.Files["report_file"];
            HttpPostedFileBase whole_file = Request.Files["whole_file"];

            d_project.report_file = "~/Upload/" + d_project.p_id + "/" +"report/"+ report_file.FileName;
            d_project.paper_file = "~/Upload/" + d_project.p_id + "/" + "paper/"+paper_file.FileName;
            d_project.whole_file = "~/Upload/" + d_project.p_id + "/" + "wholefile/"+whole_file.FileName;

                if (BLL.DeclareService.declareProject(d_project))
                {
                    Common.UpLoadServer.UploadFile(d_project, report_file, report_file, whole_file);
                }
                return Content("a");
        }
开发者ID:zhangchaodian,项目名称:Project,代码行数:58,代码来源:UserManagerController.cs

示例4: Save

        public ActionResult Save(FormCollection form)
        {
            List<string> names, dates, descriptions, costs;

            //Get values
            names = new List<string>(form.GetValues("name[]"));
            dates = new List<string>(form.GetValues("date[]"));
            descriptions = new List<string>(form.GetValues("description[]"));
            costs = new List<string>(form.GetValues("cost[]"));

            string formName = string.Empty;
            //Create new form

            if (!string.IsNullOrEmpty(form["formName"]))
            {
               formName = form["formName"];
            }

                 // TODO: validation
                double totalCost = costs.Sum(c => double.Parse(c));
       
            Models.Form newForm = new Models.Form();
            newForm = FormHelper.Create(formName,totalCost);

          
           

            
            using (ExpenseEntities db = new ExpenseEntities())
            {
                Models.Expense expense;
                for (int i = 0; i < names.Count; i++)
                {
                    
                    expense = new Models.Expense();
                    expense.Id = Guid.NewGuid();
                    expense.Name = names[i];
                    expense.Date = DateTime.Parse(dates[i]);
                    expense.Description = descriptions[i];
                    expense.Cost = int.Parse(costs[i]);
                    expense.FormId = newForm.Id;
                    expense.StateId = newForm.StateId;
                    db.Expenses.Add(expense);
                }
                          
                db.SaveChanges();
            }
           



            return RedirectToAction("New","Expense");
        }
开发者ID:enjinir,项目名称:Expense,代码行数:53,代码来源:ExpenseController.cs

示例5: Editer

        public ActionResult Editer(int id, FormCollection collection)
        {
            try
            {
                client.modMatch(id, int.Parse(collection.GetValues("IdJediVainqueur").First()), collection.GetValues("Jedi1").First(), collection.GetValues("Jedi2").First(), collection.GetValues("Stade").First());

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:bahumbert,项目名称:JediTournament,代码行数:13,代码来源:MatchController.cs

示例6: Editer

        public ActionResult Editer(int id, FormCollection collection)
        {
            try
            {
                client.modStade(id, int.Parse(collection.GetValues("NbPlaces").First()), collection.GetValues("Nom").First(), collection.GetValues("Planete").First(), null, null, null, null);

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:bahumbert,项目名称:JediTournament,代码行数:13,代码来源:StadeController.cs

示例7: ValidateSessionFormData

        /// <summary>
        /// validiert die Formulareingaben auf Korrektheit
        /// </summary>
        /// <param name="formData">FormCollection mit den Formulareingaben aus dem Create-Formular</param>
        /// <param name="numExercises">Anzahl der Uebungen im Plan</param>
        /// <returns>true oder false</returns>
        public bool ValidateSessionFormData(FormCollection formData, int numExercises)
        {
            // workoutID und anzahl der Workouts muss numerisch sein
            byte dayID = 0;
            int workoutID = -1;
            if (!Byte.TryParse(formData.Get("dayID"), out dayID) || !Int32.TryParse(formData.Get("workoutID"), out workoutID)) return false;

            DateTime workoutDate = DateTime.MinValue;
            if (formData.Get("session-date").Trim() == "" || !DateTime.TryParse(formData.Get("session-date"), out workoutDate) || workoutDate == DateTime.MinValue)
            {
                return false;
            }

            // pruefen, dass alle Wiederholungs- und Gewichtszahlen numerisch und in einem gewissen Rahmen liegen
            int tmp = -1;
            double dtmp = -1.0;
            string[] weight, reps;
            for (int i = 0; i < numExercises; i++)
            {
                reps = formData.GetValues("reps-" + i);
                weight = formData.GetValues("weight-" + i);
                if ((reps != null || weight != null) && reps.Length != weight.Length) return false;

                for (int j = 0; j < reps.Length; j++)
                {
                    if (!String.IsNullOrEmpty(reps[j].Trim()) && (!Int32.TryParse(reps[j], out tmp) || tmp < 0 || tmp > 1000)) return false;
                    if (!String.IsNullOrEmpty(reps[j].Trim()) && (!Double.TryParse(weight[j], out dtmp) || dtmp < 0.0 || dtmp > 1000.0)) return false;
                    if ((String.IsNullOrEmpty(reps[j].Trim()) && !String.IsNullOrEmpty(weight[j].Trim())) || (!String.IsNullOrEmpty(reps[j].Trim()) && String.IsNullOrEmpty(weight[j].Trim()))) return false;
                }
            }

            return true;
        }
开发者ID:m-boldt,项目名称:Exercise-Yourself,代码行数:39,代码来源:SessionService.cs

示例8: Create

		public ActionResult Create(FormCollection collection) {
			try {
				ServiceReference.JediWS jedi = new JediWS();
				List<CaracteristiqueWS> caracList = new List<CaracteristiqueWS>();

				using(ServiceReference.ServiceClient service = new ServiceClient()) {
					service.getCaracteristiques().ForEach(x => {
						if(x.Type == ServiceReference.ETypeCaracteristiqueWS.Jedi) {
							caracList.Add(x);
						}
					});

					/* Item1. sur le champs du jedi parce que on a un tuple */
					jedi.Id = 0; // Car creation
					jedi.Nom = Convert.ToString(collection.Get("Item1.Nom"));
					jedi.IsSith = Convert.ToBoolean(collection.Get("Item1.IsSith") != "false"); // Pour que ca marche bien
					jedi.Caracteristiques = new List<CaracteristiqueWS>(); // Pour init

					string[] checkboxes = collection.GetValues("caracteristiques");
					if(checkboxes != null) {
						foreach(string s in checkboxes) {
							//On a que les ids des box selected, on ajoute les caracteristiques
							Int32 caracId = Convert.ToInt32(s);
							jedi.Caracteristiques.Add(caracList.First(x => x.Id == caracId));
						}
					}

					service.addJedi(jedi); // Ajout du jedi
				}

				return RedirectToAction("Index"); // Retour a l'index
			} catch {
				return RedirectToAction("Index");
			}
		}
开发者ID:BBS007,项目名称:WebServiceJedi,代码行数:35,代码来源:JediController.cs

示例9: Create

		public ActionResult Create(FormCollection collection) {
			try {
				ServiceReference.StadeWS stade = new StadeWS();
				List<CaracteristiqueWS> caracList = new List<CaracteristiqueWS>();

				using(ServiceReference.ServiceClient service = new ServiceClient()) {
					service.getCaracteristiques().ForEach(x => {
						if(x.Type == ServiceReference.ETypeCaracteristiqueWS.Stade) {
							caracList.Add(x);
						}
					});

					/* Item1 parce qu'on a un Tuple */
					stade.Id = 0;
					stade.Planete = Convert.ToString(collection.Get("Item1.Planete"));
					stade.NbPlaces = Convert.ToInt32(collection.Get("Item1.NbPlaces"));
					stade.Caracteristiques = new List<CaracteristiqueWS>();

					string[] checkboxes = collection.GetValues("caracteristiques");
					if(checkboxes != null) {
						foreach(string s in checkboxes) {
							Int32 caracId = Convert.ToInt32(s);
							stade.Caracteristiques.Add(caracList.First(x => x.Id == caracId));
						}
					}

					service.addStade(stade);
				}
				return RedirectToAction("Index");
			} catch {
				return RedirectToAction("Index");
			}
		}
开发者ID:BBS007,项目名称:WebServiceJedi,代码行数:33,代码来源:StadeController.cs

示例10: Create

        public ActionResult Create(FormCollection collection)
        {
            try
            {
                model = new Categorias(Session);
                Categoria Categoria = new Categoria();
                Categoria.Nome = collection["Nome"];

                string[] Subcategorias = collection.GetValues("Subcategoria");

                List<Categoria> ListSubcategoria = new List<Categoria>();

                foreach (string nome in Subcategorias)
                {
                    if (String.IsNullOrWhiteSpace(nome)) continue;

                    Categoria Subcategoria = new Categoria();
                    Subcategoria.Nome = nome;

                    if (!String.IsNullOrWhiteSpace(Subcategoria.Nome))
                        ListSubcategoria.Add(Subcategoria);
                }
                Categoria.SubCategorias = ListSubcategoria.ToArray();

                model.Create(Categoria);
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
开发者ID:jsabino,项目名称:Arreceba,代码行数:32,代码来源:CategoriaController.cs

示例11: Create

        public ActionResult Create(FormCollection form)
        {
            var userId = Int32.Parse(form["userId"]);
            var siteName = form["sites"];

            var ctx = new App_Data.StackFlairDataContext();
            var site = ctx.StackSites.Where(s => s.Url == siteName).Single();

            var associationId = StackyWrapper.GetAssociationId(userId, site);
            var options = "";
            if (form.GetValues("beta").Contains("true")) { options += ",noBeta";  }
            if (!form.GetValues("combined").Contains("true")) { options += ",only=" + site.KeyName; };
            if (!form["themes"].Equals("default")) { options += ",theme=" + form["themes"]; }
            if (!string.IsNullOrEmpty(options)) { options = "/options/" + options.Substring(1); }
            string url = "~/Generate" + options + "/" + associationId.ToString() + "." + form["format"];
            //return Content(url);
            return Redirect(url);
            //return View("Default");
        }
开发者ID:rchern,项目名称:StackFlair,代码行数:19,代码来源:HomeController.cs

示例12: SaveSets

        /// <summary>
        /// liest die einzelnen Saetze einer Session aus der FormCollection aus und speichert sie in der Datenbank
        /// </summary>
        /// <param name="formData">FormCollection mit den Daten aus dem Formular</param>  
        /// <param name="numExercises">number of exercises in the workout plan</param>
        public void SaveSets(FormCollection formData, ml_Session session, int numExercises)
        {
            int workoutID = Convert.ToInt32(formData.Get("workoutID").ToString());
            byte dayID = Convert.ToByte(formData.Get("dayID"));

            string[] weight, reps;
            for (int i = 0; i < numExercises; i++)
            {
                reps = formData.GetValues("reps-" + i);
                weight = formData.GetValues("weight-" + i);

                // einzelne Saetze speichern
                for (int j = 0; j < reps.Length; j++)
                {
                    if (String.IsNullOrEmpty(weight[j].Trim()) || String.IsNullOrEmpty(reps[j].Trim())) continue;
                    saveSet(session.ID, i, j, Convert.ToDouble(weight[j]), Convert.ToInt32(reps[j]));
                }
            }
        }
开发者ID:m-boldt,项目名称:Exercise-Yourself,代码行数:24,代码来源:SessionSetService.cs

示例13: Index

 public virtual ActionResult Index(FormCollection formCollection)
 {
     var selectedValues = formCollection.GetValues("selectCheckBox");
     if (selectedValues != null && selectedValues.Count() > 1)
     {
         var selectedIds = selectedValues.Select(int.Parse).ToList();
         TempData["selectedIds"] = selectedIds;
         return RedirectToAction(MVC.TeamGeneration.Display());
     }
     return RedirectToAction(MVC.TeamGeneration.Index());
 }
开发者ID:k-o-t-n,项目名称:SfwFootball,代码行数:11,代码来源:TeamGenerationController.cs

示例14: Assignment

        public ActionResult Assignment(FormCollection collection)
        {
            string[] assignments = collection.GetValues("assignment");
            foreach (string item in assignments)
            {
                string str = item;
            }
            ViewBag.Attendees = attendeeService.GetAll();
            ViewBag.SupportTeams = service.GetAll();

            return View();
        }
开发者ID:nhuang,项目名称:fvs,代码行数:12,代码来源:SupportTeamController.cs

示例15: Index

        public ActionResult Index(FormCollection values)
        {
            var viewModel = new SearchViewModel();
            if (values.GetValues("IsWalkingDistance") != null)
            {
                setFormValues(values, viewModel);
            }
            else
                viewModel.Styles = GetStyleListOptions();

            return View(viewModel);
        }
开发者ID:Aphramzo,项目名称:WhereShouldWeEatForLunch,代码行数:12,代码来源:SearchController.cs


注:本文中的System.Web.Mvc.FormCollection.GetValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。