【发布时间】:2017-05-29 13:23:55
【问题描述】:
我为复选框创建了一个列,我想向已选中的用户发送电子邮件。我该怎么做呢?非常感谢您的帮助!
Image output from the code I created - Send Email
控制器:
public ActionResult SendEmail()
{
using (DatabaseEntities dbc = new DatabaseEntities())
{
DbSet<user> dbs = dbc.users;
ViewBag.ButtonText = "Send Reminder Email";
return View("View", model);
}
}
View.cshtml
@using SendEmail.Models @model List
<user>
@{ Layout = "~/Views/Shared/_Layout.cshtml"; }
<h2>@ViewBag.ButtonText</h2>
$(document).ready(function() {
$('#checkBoxAll').click(function() {
if ($(this).is(":checked"))
$('.chkCheckBox').prop('checked', true);
else
$('.chkCheckBox').prop('checked', false);
});
});
</script>
@if (ViewBag.ButtonText == "Send Email") {
<table>
<tr>
<th>Name</th>
<th>Email</th>
<th>
<input type="checkbox" id="checkBox" />Select All</th>
</tr>
@foreach (user u in Model) {
<tr>
<td>@i.name</td
<td>@u.email</td>
<td>
<input type="checkbox" class="chkCheckBox1" value="@u.id"/>
</td>
</tr>
}
</table>
}
<div>
<p>
<input type="submit" value="Send" />
</p>
</div>
【问题讨论】: