zoukankan      html  css  js  c++  java
  • MVC html.beginform & ajax.beginform

    1、指定表单提交方式和路径等

     @using (Html.BeginForm("Index", "Home", FormMethod.Get, new { name = "nbform", id = "nbform" }))

    他将在客户端产生一个类似<form action="/account/login" method="post"></form>标签

    2、指定表单提交为数据方式

     @using (Html.BeginForm("ImportExcel", "Stock", FormMethod.Post, new { enctype = "multipart/form-data" }))

     注意, 有时候要加{id=1}不然在点击超过第一页的索引时form后面会自动加上当前页的索引,如果此时再搜索则可能会出来“超出索引值”的错误提示
           @using (Html.BeginForm("Index", null, new { id = 1 }, FormMethod.Get))

    3、下面的操作可以防止提交链接后面自带参数

    @using (Html.BeginForm("AddDIYBillOfLading", "BillOfLading", new { id ="" }, FormMethod.Post, new { name = "myform", id = "myform" }))

    即,RouteValues的id=""

    4、

    @using (Html.BeginForm("Search", ViewContext.RouteData.GetRequiredString("Controller"), new RouteValueDictionary { { "id", "" } }, FormMethod.Get))

    RouteValueDictionary:路由对象内部存放中间值使用的对象,比如Url模板的默认值,命名空间,地址栏传过来的参数等等;当然也可以用来存放任何Key-Value形式的任何值;http://www.cnblogs.com/Leo_wl/p/3380570.html

  • 相关阅读:
    手写RPC
    随机生成6位的字符串验证码,要求包含数字,大小写字母
    输出学习阶段目标
    吃货联盟
    判断是否为整数
    实现一个登录注册功能
    作业1
    年龄异常
    作业2
    作业1
  • 原文地址:https://www.cnblogs.com/chrisghb8812/p/5608127.html
Copyright © 2011-2022 走看看