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

  1. #1

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

    Our asp.net application uses EXT.NET. When a "View" menu is clicked, an EXT.NET window shows up with a content of a PDF file. The problem is we can't drag and drop that window to a body of an Outlook email (to make it as the email attachment).

    I am thinking one of the way to drag and drop to a body of an Outlook email is to show the PDF file in the browser window, not an EXT.NET window. How can I do that ? Thank you.

    This is from the View (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;
                                            })
    This is from 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;
        }
  2. #2
    If I want to add this in the view:

    <a href="Url.Action("ArcTicket", new {download=ViewBag.Download})" target="_blank">Download</a>

    Where shall I add that in my View ?

Similar Threads

  1. [CLOSED] submitting file to ashx in IE browser
    By odyssey in forum 2.x Premium Help
    Replies: 4
    Last Post: Jul 14, 2014, 9:46 AM
  2. Replies: 2
    Last Post: Jun 13, 2014, 10:52 AM
  3. Replies: 2
    Last Post: Jul 12, 2013, 4:45 PM
  4. Replies: 3
    Last Post: Mar 19, 2012, 1:35 PM
  5. Replies: 2
    Last Post: Sep 22, 2010, 1:17 PM

Tags for this Thread

Posting Permissions