asp.net-mvc – 添加附加参数以表单提交
发布时间:2020-12-16 00:21:39 所属栏目:asp.Net 来源:网络整理
导读:我的剃须刀视图中有一个表单声明 form method="post" action="/Lot/LotList?auctionEventId=@auctionEventId" id="filterForm" (顺便提一下,我选择这样写出来,而不是使用Html.BeginFrom,因为我需要给它一个id,不知道如何使用Html.BeginFrom – 但这不是
我的剃须刀视图中有一个表单声明
<form method="post" action="/Lot/LotList?auctionEventId=@auctionEventId" id="filterForm"> (顺便提一下,我选择这样写出来,而不是使用Html.BeginFrom,因为我需要给它一个id,不知道如何使用Html.BeginFrom – 但这不是这里的问题) 在此表格之外,我有一个提交此表单的按钮(表单中还有一个提交按钮) <input type="button" onclick="$('#filterForm').submit();" value="Show all" /> 现在的问题是,如果这个按钮用于提交表单,我想要的形式的动作改为 action="/Lot/LotList?auctionEventId=@auctionEventId&showAll=true" 如何更改操作并传递此附加参数?有没有一个更好的方式做这一切? 解决方法
将查询字符串参数附加到表单操作上,并尝试在运行时更改它是棘手的(但不是不可能)。更容易使用隐藏的字段:
<form method="post" action="/Lot/LotList" id="filterForm"> <input type="hidden" name="auctionEventId" value="@auctionEventId" /> ... 所以现在所有你需要做的是为“showAll”添加另一个隐藏的字段 <form method="post" action="/Lot/LotList" id="filterForm"> <input type="hidden" name="auctionEventId" value="@auctionEventId" /> <input type="hidden" name="showAll" value="false" id="showAllField" /> ... 并且只需在您的showAll按钮上连接一个jquery事件: <input id="showAllButton" type="button"/> jQuery的: $('#showAllButton').click(function(){ $('#showAllField').val("true"); $('#filterForm').submit(); }); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – HttpContext.Current.Cache可用于所有会话
- asp.net-mvc-4 – / signalr / hubs未加载到asp.net mvc4:
- asp.net – 错误BC30456:'[方法]’不是’ASP.[CodeBeh
- asp.net-mvc – ASP .Net MVC 3:单元测试控制器动作
- Asp.net MVC同名视图,路径不同
- asp.net-mvc – ASP.Net MVC,动态属性和EditorFor / LabelF
- asp.net-mvc – 无法弄清楚为什么模型在回发时为null?
- asp-classic – 从头开始??在Visual Studio 2010中创建经典
- ASP.NET Core 1 RC2 Web应用入门点
- asp.net-mvc-3 – ModelState.AddModelError不显示在我的视
推荐文章
站长推荐
- asp.net-mvc – nhibernate:具有相同标识符值的
- asp.net – 如何在更新面板刷新后运行一些javasc
- asp.net – 如何在代码后面访问span id
- asp.net – IIS分段和生产交换
- ASP.NET Core使用SkiaSharp实现验证码的示例代码
- asp.net-mvc – 在Controller操作方法中重用代码
- asp.net-mvc-3 – 为什么Ninject不会解析基类中的
- asp.net-mvc – 在实体框架中使用存储过程
- asp.net – ajax中的Updatepanel总是运行page_lo
- 如何在asp.net mvc 3中禁用浏览器缓存?
热点阅读