0

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/[email protected]&[email protected]','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 ?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.