码迷,mamicode.com
首页 > 其他好文 > 详细

form表单中隐藏类型input的使用

时间:2018-03-12 13:38:16      阅读:221      评论:0      收藏:0      [点我收藏+]

标签:div   redirect   color   dir   col   ==   response   pos   new   

<form action="PersonSave.ashx" method="post">
        <input type="hidden" name="action" value="{action}"/>
        <input type="hidden" name="id" value="{id}"/>
        姓名:<input type="text" name="name" value="{name}" />年龄:<input type="text" name="age" value="{age}" />
        性别:(选上就是男的)<input type="checkbox" name="gender" {gender} />
        <input type="submit" value="保存" />
    </form>

表单保存时,若action为edit,那么后台则需要一个id来具体update哪条数据

        if (action=="edit")
            {
                int id = Convert.ToInt32(context.Request["id"]);
                SqlHelper.ExecuteNonQuery("update T_Persons set Name=@Name,Age=@Age,Gender=@Gender where Id=@Id",
                    new SqlParameter("@Name", strName),
                    new SqlParameter("@Age", strAge),
                    new SqlParameter("@Gender", (strGender!=null)),
                    new SqlParameter("@Id", id));
                context.Response.Redirect("PersonList.ashx");
            }
          

 

form表单中隐藏类型input的使用

标签:div   redirect   color   dir   col   ==   response   pos   new   

原文地址:https://www.cnblogs.com/HuShaoyi/p/8548386.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!