我试图通过单击ActionLink并传递如下参数来在同一页面上打开我的引导模式:
- @foreach (Items item in Model)
- {
- @Html.ActionLink("Download","#",new { data-id = '@item.Name' } )
- }
- //Modal
- <div id="dModal" class="modal hide fade" aria-hidden="true">
- <div class="modal-body">
- @using (Html.BeginForm("getCSV","Download",new { filename = data-id },FormMethod.Post,null))
- {
- <button id="btnCSV" type="submit">Download CSV</button>
- }
- //other options for excel,word etc
- </div>
- </div>
在ActionLink中,我将actionName参数保留为#,这是因为模式位于同一页面上,当用户选择模态中的选项时,将决定操作.不直接调用下载操作方法的原因是因为用户可以选择以各种格式下载excel,csv等.