zoukankan      html  css  js  c++  java
  • MVC 如何取得View中的值传到Controller

    在Controller里可以用FormCollection去取得View上控件的值,不过Button类型的取不到。

    例子如下:

    public ActionResult Allot(FormCollection _formCollection)
    {

    string[] str = _formCollection["functions"].ToString().Split(',');

    int s = int.Parse(_formCollection["authorityid"]);

    }

    前台代码

    <span>权限名称:@k
    <input type="hidden" value="@id" name="authorityid" />
    </span>
    <br />
    <span>功能项:</span><br />
    @foreach (var item in ViewBag.functions as IEnumerable<MYJPS.Models.Function>)
    {
    <input type="checkbox" value="@item.FunctionID" name="functions" />@item.Name<br />
    }
    <input type="submit" value="确认" />

  • 相关阅读:
    java
    MVC4重复提交数据
    cache
    Nosql
    MVC4重复提交
    PHP Java
    .net performance
    How the Runtime Locates Assemblies
    android
    window.onscroll
  • 原文地址:https://www.cnblogs.com/BuBu/p/2663322.html
Copyright © 2011-2022 走看看