Open window with pdf or html content from disk (external to iis)
Hello!
i need open document from external path my server in new window..
on my grid i have command column and after click pass in direct event 2 param : ext ( pdf or html) and full path to them
Code:
<ext:CommandColumn ID="CommandColumn1" runat="server" Width="60" >
<PrepareToolbar Fn="prepareToolbar" />
<Commands>
<ext:GridCommand Icon="Page" CommandName="View">
<ToolTip Text="Посмотреть" />
</ext:GridCommand>
</Commands>
<DirectEvents>
<Command OnEvent="ShowDoc" Success="onAfterShowDoc" IsUpload="true" >
<%-- <EventMask ShowMask="true" />--%>
<ExtraParams>
<ext:Parameter Name="ext" Value=record.data.col6 Mode="Raw" />
<ext:Parameter Name="link" Value=record.data.col1 Mode="Raw" />
</ExtraParams>
</Command>
</DirectEvents>
on the server side i found 2 examples..
this work for me.. but open dialog - where i must select open or save..
Code:
protected void ShowDoc(object sender, DirectEventArgs e)
{
string ext = e.ExtraParams["ext"];
string link = e.ExtraParams["link"];
FileInfo file = new FileInfo(link);
// Checking if file exists
if (file.Exists)
{
Response.ClearContent();
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
if (ext == "pdf")
Response.ContentType = "application/pdf";
else
Response.ContentType = "application/html";
Response.TransmitFile(file.FullName);
Response.End();
}
}
and two examples - open content in window ( the same what i want)
Code:
protected void ShowDoc(object sender, DirectEventArgs e)
{
string ext = e.ExtraParams["ext"];
string link = e.ExtraParams["link"];
var win = new Ext.Net.Window()
{
ID = "newDocument",
Title =ext,
Width = Unit.Pixel(1000),
Height = Unit.Pixel(600),
Modal = true,
Collapsible = false,
Maximizable = true,
BodyStyle = "padding:10px;",
AnimateTarget = sender.ToString(),
Icon = Icon.PageWhiteAcrobat,
Loader = new ComponentLoader
{
Url = link, // this link only internal for IIS.??. i want open from net share path.. html and pdf file
Mode = LoadMode.Frame,
LoadMask = { ShowMask = true },
MonitorComplete=true
}
};
win.Render(this.Form1);
}
may be help me edit 2 example.. if link to file inside server ( like 1.pdf) this work fine, but if link="G:\wert yuio\asdd 2323\232 555.pdf " - not open..
thanks..
Open window with pdf or html content from disk (external to iis) -
I have tried replicating this solution in my application, and it works just fine in Internet Explorer.
But with Chrome, it doesn't display the content of the files in the window, it only downloads the files.
Would you know how can I get it to display file content in the window in Chrome?
Chrome specifically blocks local file access this way for security reasons.
dharamehta
Chrome specifically blocks local file access this way for security reasons.
https://stackoverflow.com/questions/...local-resource
firefox,ie - ok
Open window with pdf or html content from disk (external to iis) -
That makes sense. Thanks asics167.
Open window with pdf or html content from disk (external to iis) -
I want to be able to open these files in a new browser tab instead of a modal window. Is there a way to do that?