asp.net-mvc – 添加附加参数以表单提交
发布时间:2020-05-23 19:14:59 所属栏目: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-mvc – MVC 4 ModelBinder
- ASP.NET C#ListBox服务器控件不会禁用
- asp.net-mvc – 使用web.config关闭MVC中的身份验证
- 看起来像asp.net mvc中的日期工具不正确
- asp.net – 问题检查后面的代码中的单选按钮
- asp.net – 如何在KeyUp上进行文本框回发?
- 有条件地排除ASP.NET WebForms中的一个HTML块
- asp.net-mvc – 从基本控制器继承LINQ-to-SQL数据上下文
- asp.net-web-api – 为什么我的ApiController方法的ModelSt
- ASP.NET MVC:如何在MVC应用程序中使用静态HTML页面?
