Jan 09, 2014, 5:06 PM
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
this work for me.. but open dialog - where i must select open or save..
thanks..
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
<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..
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) 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..
Last edited by asics167; Jan 10, 2014 at 4:27 AM.
Reason: edit proc 2