我有一个列表视图,我想用一个下拉列表和一些复选框对其进行过滤。 See image
这是我认为的代码:
<div>
<table border=0 id="idpagetitle">
<tr>
<td style="width: 480px; width:330px">
<center>
<font color=black>
<b>Show:</b>
</font>
<select id="location_id" style="width:200px">
<option value="default"> - </option>
<option value="all" selected>All Locations</option>
<option value='23'>Location X</option>
<option value='15'>Location Y</option>
</select>
</center>
</td>
<td class="pagetitlelabel" width="400">
<table border=0>
<tr>
<td><input type="checkbox" id="all"> All</td>
<td><input type="checkbox" id="active"> Active</td>
<td><input type="checkbox" id="paid"> Paid</td>
<td><input type="checkbox" id="receivables"> Receivables</td>
</tr>
<tr>
<td><input type="checkbox" id="curmonth"> Current Month</td>
<td><input type="checkbox" id="inactive"> Inactive</td>
<td><input type="checkbox" id="unpaid"> Unpaid</td>
<td><input type="checkbox" id="payables"> Payables</td>
</tr>
</table>
</td>
<td><input type="submit" class="smallbutton" id="FilterClick" onclick="FilterClick(location_id, active, paid, receivables, curmonth, inactive, unpaid, payables)" value="Filter" /></td>
<td><input type="submit" class="smallbutton" name="cmdxls" onclick="cmdexcel()" value="All to Excel"></td>
</tr>
</table>
</div>
这是我的控制器中的代码:
public ActionResult FilterClick(int location, bool active, bool paid, bool receivables, bool curmonth, bool inactive, bool unpaid, bool payables, bool all)
{
LeaseFilterModel filter = new LeaseFilterModel();
filter.Location = location;
filter.Active = active;
filter.Paid = paid;
filter.Receivables = receivables;
filter.CurrentMonth = curmonth;
filter.Inactive = inactive;
filter.Unpaid = unpaid;
filter.Payables = payables;
filter.All = all;
LMWEBLINQDataContext leases = new LMWEBLINQDataContext();
var leaseList = (from l in leases.tblfLeaseDetails
join v in leases.tblvVendors on l.Vendor_ID equals v.Vendor_ID
join c in leases.tblvCounties on l.County_ID equals c.County_ID
join a in leases.tblfAuthorizations on l.Lease_Detail_ID equals a.Lease_Detail_ID
join t in leases.tblvLineTypes on l.Line_Type_ID equals t.Line_Type_ID
where l.Location_ID == filter.Location
select new
{
l.Lease_Detail_ID,
l.Lease_ID,
l.XRef_Lease_ID,
v.Vendor_Name,
l.Description,
c.County,
l.Amount,
l.Payment_Due_Date,
a.Authorized,
t.Line_Type
}).Distinct().ToList().ToNonAnonymousList(new List<LeaseViewModel>()).Take(10);
return View(leaseList);
}
问题:
当我运行该应用程序并单击该按钮时,它根本不会触发任何操作。请帮助我找出我做错了什么。
参考方案
对于服务器端方法,您需要使用BeginForm帮助器。因此,最好的方法是将您的视图更改为以下形式:
@using (Html.BeginForm("yourmethodname", "yourcontrollername", new { id = "FilterClick" }, FormMethod.post,null ))
{
<input type="submit" class="smallbutton" id="FilterClick" value="Filter" /> }
将Web用户控件添加到页面时,asp按钮onclick不会触发 - javascript我正在使用使用Visual Studio模板创建的Web表单应用程序。模板具有一个内容占位符,该占位符被访问的任何页面的内容替换。有问题的页面有几个服务器控件,例如文本框,标签和按钮。当我单击我的更新按钮时,它可以正常工作,这些值会回传并更新数据库。我想在所有子页面上创建通用的登录提示。我的导航栏(位于我的母版页中)具有引导程序设置。我在导航栏中添加了一个下…
Telerik单选按钮所需的字段验证器 - javascript如何设置Telerik单选按钮所需的字段验证器?我想在按钮单击“ BtnSave”上设置必填字段验证器吗?请帮忙!<telerik:RadButton ID="radio_male" runat="server" ToggleType="Radio" AutoPostBack="fa…
用symfony隐藏树枝中的表格行 - javascript我正在开始编码。我正在使用Symfony 3.3我想用复选框隐藏(并显示)表上的a或某些特定行。我尝试使用javascript和jquery。我希望隐藏的行保持隐藏状态。我不知道该怎么做。这是我的树枝{% block body %} <div class="container"> <h3>List of produ…
表单不提交或按钮提交不起作用 - javascript据我所知,此代码必须有效,但是我编码时却无效问题在于该表单未提交。我该如何解决?选中时,我什至没有得到复选框的值。<table id="example" class="display" cellspacing="0" width="100%"> <thead&g…
在PHP文件中调用javascript函数并在加载HTML文件之后? - javascript我需要在我的php中调用js函数,但无法正常工作。有人可以告诉我我在做什么错吗?我该如何轻松地做到这一点?谢谢!我有三个文件: mail.php负责发送$ _POST的内容(工作正常)。我调用我的javascript函数来切换模式,具体取决于邮件是否已发送。 <? ... $response = $sendgrid->send($email);…