|
Rank: Member Groups: Member
Joined: 11/19/2007 Posts: 25
|
Hi, I have a page with the File Explorer which includes an html input type button. The onclick opens a diaglog with a content url passing the filepath from the textbox used with the File Explorer. My JavaScript can filter the allowable file types that way. The content url produces a download, but leaves me with an empty dialog that the user must close. I know that I could callback, set a session var then start the download. Would it be possible you to modify the client Downloader.start() method so I could pass in this file path? Is there another way? Thanks
Code: C#
//access to this page is controlled by the http handler and the resources table in the authorization database
if (Request.QueryString["File"] != null && Request.QueryString.Get("File") != string.Empty)
{
file = Request.QueryString.Get("File");
filepath = this.MapPath(this.Server.UrlDecode(file));
if (File.Exists(filepath))
{
string filename = filepath.Substring(filepath.LastIndexOf("\\") + 1).Replace(" ", "_");
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename=" + filename);
Response.TransmitFile(filepath);
Response.End();
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
I am not exactly sure whether I got the full picture clearly. Can you provide a full test page/project with step by step instruction on how and what you want to do?
Thanks!
|
|
Rank: Member Groups: Member
Joined: 11/19/2007 Posts: 25
|
I could set something up to demonstrate my current technique, but please allow me an attempt at a better explanation of what I'd like to do first.
1) Use the download control with DynamicContent=true. 2) Set FilePath using JavaScript and setting SaveAsFileName in the Download event handler. 3) Start the download using JavaScript (can do this now, but I don't think I can easily set the FilePath from the client). 4) Respond using ContentGenerator.WriteFile().
I was wondering why the DownloadButtonID can't also be your ScriptEvent control?
Basically, I want to use the control in conjunction with the File Explorer and the textbox holding the virtual file path. I could then get the value on the client and send it to the server with the download request. I haven't tried using cookies yet or I suppose I could send the file path with a callback, hold it as a session value then request the download using javascript.
If I could do what is described, I wouldn't need a server control for a DownloadButtonID unless it was the ScriptEvent control.
Am I missing the way to do what I want easily with current functionality? I realize there may be a technical reason that the control doesn't function like this.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
You call start() method with JavaScript to start the download. The restriction is you will need to call start from a mouse click event handler. For example, you can't call start() method inside a timer and forcefully "push" files to your site visitor. Like upload, every download must be initiated by a direct user action.
I do not know how you intend to use the downloader and FileExplorer or ScriptEvent together, but the fundamental principle is as above. So if you are planning to launch FileExplorer from mouse click, then have the FileExplorer "automatically" downloads some file to the client, then you will not be able to do it because the downloader must be triggered by a direct user action.
I do not believe you can leave DownloadButtonID empty though. If you don't use it, you can set it to a Button but then include that Button inside a div with style="display:none". That way the button won't be visible.
Thanks
|
|
Rank: Member Groups: Member
Joined: 11/19/2007 Posts: 25
|
I would have an html input type='button' on the same page as the file explorer to initiate the download. The reason I brought the topic up is for a feature request because I can't use the control the way I'd like to. But, now that I have expressed that there is no reason to continue the discussion.
Thanks
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
In that case it should work for you. I don't think you need to set FilePath when using dynamic download.
|
|