我有问题从视图调用方法到控制器。
SendVotingPanel.cshtml
@model EmailTemplete.Models.SendVotingEmail
@{
ViewBag.Title = "SendVotingPanel";
}
<h2>SendVotingPanel</h2>
<meta charset="utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.2/themes/base/jquery-ui.css" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script type="text/javascript"` src="/resources/demos/external/jquery.bgiframe-2.1.2.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script type="text/javascript">
function Send() {
$(function() {
$("#dialog").dialog();
});
};
</script>
<input type="button" value="submit" id="openpopup" onclick="Send();"/>
@using (Html.BeginForm())
{
<div style="display:none" id="dialog">
<div class="editor-label">
@Html.LabelFor(model => model.ContactEmail)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.ContactEmail)
@Html.ValidationMessageFor(model => model.ContactEmail)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Subject)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Subject)
@Html.ValidationMessageFor(model => model.Subject)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.Message)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.Message)
@Html.ValidationMessageFor(model => model.Message)
</div>
<br />
<p>
<input type="submit" value="Save"/>
</p>
</div>
}
控制器
public ActionResult SendVotingPanel()
{
return View();
}
[HttpPost]
public ActionResult SendVotingPanel(Models.SendVotingEmail model)
{
return View(model);
}
当我点击 openpopup 按钮时,会显示一个弹出窗口。当我用一些数据填充所有文本框并单击按钮时,我无法调用方法 SendVotingPanel 。 我的代码是否有任何变化?
答案 0 :(得分:1)
尝试更改:
@using (Html.BeginForm())
{
<div style="display:none" id="dialog">
...
</div>
}
要:
<div style="display:none" id="dialog">
@using (Html.BeginForm())
{
...
}
</div>