单击提交按钮时,我想生成一个显示项目列表的弹出窗口。我试图创建弹出的代码如下:`
索引视图:
<script type="text/javascript">
$('#popUp').Hide();
$('#button').click(function () {
$('#popUp').click();
});
</script>
<div class="left-panel-bar">
@using (Html.BeginForm(FormMethod.Post))
{
<p>Search For: </p>
@Html.TextBox("companyName",Model);
<input id="button" type="submit" value="Submit" />
}
</div>
<div id="popUp">
@Html.ActionLink("Get Company List", "CreateDialog", "Company", null, new
{
@class = "openDialog",
data_dialog_id = "emailDialog",
data_dialog_title = "Get Company List"
});
</div>
但我在使用此代码时遇到了麻烦。当我单击提交按钮时,它会打开另一个页面而不是弹出窗口。控制器代码如下:
[HttpPost]
public ActionResult Index(Companies c)
{
Queries q1 = new Queries(c.companyName);
if (Request.IsAjaxRequest())
return PartialView("_CreateDialog", q1);
else
return View("CreateDialog", q1);
}