I am new to asp.net mvc. I have a button on my page. On click of that button I want to show download dialog box only. I don't want to call any other view and controller. Whenever I use @Html.BeginForm("Index", "Download", FormMethod.Post)
, it opens new window along with download dialog box. I don't want to open any new window. My code is as follows
@Html.BeginForm("Index", "Download", FormMethod.Post)
{
@{if (check.CheckName != "Total")
{
<td colspan="2" align="right">
<span class="button">
<input type="submit" value="View Report" class="form_button" onclick="window.showModalDialog('/Download/Index?EmployeeID=@Model.EmployeeInformation.EmployeeID&RequestID=@Model.RequestInformation.RequestID','Download View','dialogHeight:4px;dialogWidth:4px;');" /></span>
</td>
<td colspan="2" align="left">
<span class="button">
<input type="submit" value="Download Report" class="form_button" /></span>
</td>
}
}
Is there any way to do this ?
you can use Ajax.BeginForm this can update just a part of your page with your form content without the need to open a new page.
@using (Ajax.BeginForm("Index", "Download", new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "area", // the div that will have your form contents
InsertionMode = InsertionMode.Replace
}))
{
// here you can put your form content normally like the 'Html.BeginForm'
}
<div id = "area">
</div>
and make your Action returns a PartialView.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.