asp.net ext.net 在浏览器中显示新文件 window

asp.net ext.net show file in browser new window

我们的 asp.net 应用程序使用 EXT.NET。 单击 "View" 菜单时,将显示 EXT.NET window,其中包含 PDF 文件的内容。 问题是我们无法将 window 拖放到 Outlook 电子邮件的正文中(使其成为电子邮件附件)。

我在想拖放到 Outlook 电子邮件正文的方法之一是在浏览器中显示 PDF 文件 window,而不是 EXT.NET window .我怎样才能做到这一点 ? 谢谢。

这是来自视图 (Index.cshtml):

@{
ViewBag.Title = "Archive";
var X = Html.X();
}

@section SPAViews {
@(
X.Viewport().Layout(LayoutType.Fit).Items(
X.TabPanel().ID("ArchiveTabPanel")
.Items(
        X.GridPanel().ID("GridPanel1").MarginSpec("1 1 1 1").Cls("cust-grid").Title("Archive").Icon(Icon.ServerCompressed)
        .Plugins(X.GridFilters())
        .View(Html.X().GridView().StripeRows(true).TrackOver(false))
        .SelectionModel(X.CheckboxSelectionModel().Mode(SelectionMode.Multi))
        .TopBar(
            X.Toolbar().MinHeight(35)
                .Items(
            :
                            , X.Button()
                                    .Text("View")
                                    .Icon(Icon.PageWhiteAcrobat)
                                        .DirectEvents(de =>
                                        {
                                            de.Click.Action = "Submit";
                                            de.Click.EventMask.ShowMask = true;
                                            de.Click.Method = HttpMethod.POST;
                                            de.Click.ExtraParams.Add(new Parameter()
                                            {
                                                Name = "selection",
                                                Value = "getselection()",
                                                Mode = ParameterMode.Raw
                                            });
                                            de.Click.Timeout = 360000;
                                        })

本文来自ArchiveController.cs:

    public ActionResult Submit(string selection)
    {
            int cnt = SetTempData(selection);
            RenderWindows(String.Format("View Archive {0}.",cnt),0,cnt);
            return this.Direct();
   }

    [ChildActionOnly]
    public void RenderWindows(string title,int download,int cnt)
    {
        Window win = new Window
        {
            ID = "Windows1",
            Title = title,
            Icon = Ext.Net.Icon.PageWhiteAcrobat,
            Height = download == 1 ? 150 : 600,
            Width = download == 1 ? 400 : 800,
            BodyPadding = 2,
            Modal = true,
            Layout = "Fit",
            CloseAction = CloseAction.Destroy,
            Loader = new ComponentLoader()
            {
                Url = Url.Action("ArcTicket", "Archive"),
                Mode = LoadMode.Frame,
                DisableCaching = true,
                ShowWarningOnFailure = true,
                LoadMask = { ShowMask = true, Msg = String.Format("Generating {0} pdf ...",cnt) }
            },
            Buttons = {
                new Button(){ Text="Close & Clear", Icon=Ext.Net.Icon.TableRowDelete, Handler="App.GridPanel1.selModel.deselectAll();App.Windows1.close();"},
                new Button(){ Text="Close", Icon=Ext.Net.Icon.Cancel, Handler="App.Windows1.close();"}
                    }
        };
        win.Loader.Params.Add(new Parameter() { Name = "download", Value = download.ToString(), Mode = ParameterMode.Value });
        win.Render(RenderMode.Auto);
    }

    public FileStreamResult ArcTicket(int download)
    {
        String id = TempData["xid"].ToString();
        TempData.Remove("xid");
        String ticket = Uow.TICKETs.GetXmlBatch(id);

        Byte[] pdf = MvcApplication.Fop.Write(enumFobFormat.Pdf
                            , ticket
                            , Server.MapPath("/Resources/xslt/Ticket.xsl")
                            );

        MemoryStream ms = new MemoryStream(pdf);
        FileStreamResult fs = new FileStreamResult(ms, "application/pdf");
        if (download == 1)
            fs.FileDownloadName = string.Format("Archive_{0:yyyyMMdd_HHmmss}.pdf", DateTime.Now);

        return fs;
    }

您可以使用 href 制作普通按钮 / link 到 target="_blank"ArcTicket 操作然后它将在新标签页中打开

更新:

将 .TopBar 更改为类似这样的内容。选项 1 可能有问题,因为来自网格的动态参数,我不确定是否可以将它传递到那里

选项 1:

.TopBar(
            X.Toolbar().MinHeight(35)
                .Items(
            :
                            , X.Button()
                                    .Text("View")
                                    .Icon(Icon.PageWhiteAcrobat)
                                    .Href(Url.Action("ArcTicket", "Archive"))
                                    .HrefTarget("blank")
                                    .BaseParams("yourparameters")

选项 2

.TopBar(
            X.Toolbar().MinHeight(35)
                .Items(
            :
                            , X.Button()
                                    .Text("View")
                                    .Icon(Icon.PageWhiteAcrobat)
                                    .Handler("YourJSFUnctionWithWIndowOpen")