如何将复选框选中列表传递给模态弹出窗口

时间:2013-01-04 09:27:16

标签: asp.net-mvc-3

我的网页上有一个按钮和一个表格

<input type="submit" value="Email" name="button" class="openDialog" data-dialog-id="Mail Dialog" data-dialog-title="Send Mail" data-url="<%: Url.Action("SendMail") %>" />    

<form>
    <table>
        <tr>
            <th>            
                <input type="checkbox"/>           
             <input type="hidden" class="textfield" id="video0_tags" name="video0_tags" />     
            </th>
            <th>
                FirstName
            </th>
            <th>
                LastName
            </th>
        </tr>
    <% foreach (var item in Model)
       { %>
        <tr>
            <td>            
                <div class="taglist">
                <input type="checkbox" name="check" value="<%: item.ProfileId %>" /> 
                </div>
            </td>
            <td>
                <%: Html.DisplayFor(modelItem => item.FirstName)%>
            </td>
            <td>
                <%: Html.DisplayFor(modelItem => item.LastName)%>
            </td>
    <% } %>
    </table>
</form>

在我的控制器中

[HttpGet]
    public ActionResult SendMail(string video0_tags)
    {            
        return View();
    }

    [HttpPost]
    public ActionResult SendMail(int[] check,Profile profile, mail email)
    {

            foreach (var item in check)
            {
                var dbprofile = db.Profile.Single(p => p.ProfileId == item);
                string Emailid = dbprofile.EmailId;
                MailMessage msg = new MailMessage();
                MailAddress fromAddress = new MailAddress("xxxx@gmail.com");
                msg.From = fromAddress;
                msg.To.Add(Emailid);
                msg.Subject = email.Subject;
                msg.Body = email.Body;
                msg.Priority = MailPriority.High;
                SmtpClient client = new SmtpClient("smtp.gmail.com", 587);
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Credentials = new NetworkCredential("xxxxx@gmail.com", "password");
                client.EnableSsl = true;
                client.Send(msg);
            }
        return RedirectToAction("Profiles", "profile");
    }

问题

我的问题是我无法将复选框选中的值传递给弹出窗口的get actionresult。这是根据复选框选中的项目向多个成员发送电子邮件。

任何人都可以帮助我.....请

1 个答案:

答案 0 :(得分:0)

问题是复选框是一个布尔输入。

如果您将配置文件ID存储在隐藏的输入字段

中会更好

顺便说一下,不要忘记将表格包裹在表格中。

<form>
   <input type="submit" .../> 
   <table> ... </table>
</form>
相关问题