Page 1 of 1

JQButton - How to specify target as in a link

PostPosted: 20 Oct 2014 21:50
by JohnFSklavounos
Hello,

I have a "How to" kind of question... I have a JQButton which calls the WebApplication.SendFile function. All is well, but I'd like to have the browser open the file in another window or tab the way you would specify in an anchor tag in straight html. I'm hoping there's something I can add to the JQButtonOptions.OnClick.BrowserParams to make that happen.

<a href="wwwroot/temp/file.pdf" target="_blank">Download file here</a>

I can't use a link because the document is generated dynamically...

Any thoughts?

Thanks!
John

Re: JQButton - How to specify target as in a link

PostPosted: 20 Oct 2014 23:34
by Jorge Sousa
Hi John

It's a very interesting question, maybe i don't have the full answer right now.

When you call WebApplication.SendFile, depends on how browsers are configurated to handle each mime types.

If you need to open a new browser window, maybe its best if you call WebApplication.NewWindow

And you can use a link, despite the fact the document being generated dynamically, you can use IW cache functions, are you familiar with them? Maybe if you give us an hint on how are you creating the docx, we can give you a tip on how to get the correspondant url.

The BrowserParams only serves the purpose of transporting evaluated script expressions in browser, to the server, when they are needed, and only if the control doesn't do already these functions, which are always done in user changeable values, like a edit text, a combo selected index or even a grid selection change.

Re: JQButton - How to specify target as in a link

PostPosted: 21 Oct 2014 01:56
by JohnFSklavounos
Wow, exactly what the doctor ordered. You guys are amazing! 8-)

For anyone's curiosity, when using this method, do not use a windows file system file name in the URL field.

Create your file in the wwwroot\%somefoldername%\... then pass it as an actual URL relative to the root. For example, I used, 'username/sessionid/filename.ext' I did this because I wanted to be able to easily look at the what the users are up to, but feel free to use the IWAppCache if you don't need to see the files being created.

TIWAppCache Class Docs
http://docs.atozed.com/docs.dll/classes/TIWAppCache.html

Remember that if you manage the files & folders on your own, you have to create a way to clean up after yourself or the server is going to get full fast.

You guys are the best!

Thanks,
John

Re: JQButton - How to specify target as in a link

PostPosted: 21 Oct 2014 09:45
by Jorge Sousa
Hi John

Just one more thing,

And remember that if more than one user / session creates files in some wwwroot folder, make sure that the folder or filename is unique, (or that part of the code is a critical section), if not, the users can be creating the same file to the same folder, at the same time.

Re: JQButton - How to specify target as in a link

PostPosted: 21 Oct 2014 19:34
by JohnFSklavounos
Understood.

:D

Thanks again!
John