Originally posted by Jeebo72
View Post
- Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
- Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!
Reply to: Who's done the least work today?
Collapse
You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:
- You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
- You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
- If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.
Logging in...
Previously on "Who's done the least work today?"
Collapse
-
-
Nick, you never fail to impress.
The workaround that probably would have worked would have been to use a client-side event on the uploader to populate an image via Javascript. More effort that I want to spend on a nice-to-have. Ever get the feeling you're writing DailyWTF-grade code that would be avoidable if only you knew the proper way? well maybe you don't but it's a constant worry for me.
Leave a comment:
-
First week on a new job and I did pretty much nothing, what do they expect you to do when they give you a machine with 1 gig and expect you to run websphere on it?
Leave a comment:
-
Originally posted by thunderlizard View PostIt would have been nice, but not really necessary. The submit button takes them to a page that displays what they've just entered anyway. And if users don't know what image they're uploading, that's their lookout!
Originally posted by thunderlizard View PostProblem is basically this: FileUpload control doesn't work in an UpdatePanel, so I'd have to wait for a full page postback so my one-step user-enters-details-and-saves-them idea would be lost.
However, XHR will only do requests where the content-type of the form (which for some obscure reason is defined by the enctype attribute) is application/x-www-form-urlencoded. Although this is fine for most things, it doesn't allow for the upload of files. That requires the content-type multipart/form-data, and XHR cannot deal with that. (Linky to the spec, FWIW.)
Originally posted by thunderlizard View PostBrand-spanking new AsyncFileUpload has the opposite problem: it uploads the image quick as you like but doesn't trigger a postback so I can't show it on screen.
Given that XHR can't upload files we are left with one obvious fact: the browser can upload files. Therefore we make use of the browser. What we do - or, what the library does for us - is to create an iframe, hide it by positioning it off-window, assign a name to it, set the target attribute of the form to that name, assign an onload handler to the iframe, and call the form's submit method. From that point on the browser just does what it does when making a normal request-response cycle; and you'll see activity in the usual places, like throbbers and status bars.
When the iframe then loads the response to the file upload, the onload handler kicks in. When using a library, this is the point where the response is packaged up in some way and sent to your "oncomplete" (or whatever it's called) handler.
However, you now face a number of deviations from the normal situation upon receiving the response to an Ajax request:
- The XHR object's responseText and responseXML properties aren't available, as there never was an XHR object in the first place;
- If the server sent the response as text/html, and it wasn't an HTML page, the browser will probably wrap some <pre></pre> tags around it for rendering purposes (not all browsers do this);
- If the server sent the response as XML and it wasn't well-formed, the iframe might contain an XHTML error message from the browser's XML parser (Firefox does this);
- If the server sent the response as XML and it was well-formed, the iframe might contain a bunch of not-very-well-formed HTML and JavaScript that, if seen by the user, would be a pretty-printed interactive rendering of the XML (IE does this);
- If the server sent the response as text/json, the browser will probably pop up a dialog asking the user if they want to save the file to disk, as browsers don't display that content type;
- If the server sent the response as text/plain, and you wanted XML or JSON or HTML, you need to grab the plain text and find a way to parse it yourself.
- ...and other possible pitfalls.
Of course, you may also have to deal with the way your library attempts to deal with these situations: it might make things better, or worse, or just different
See what I mean about hacks and leaky abstractions?
Still, with that basic summary of the background to it all, a few minutes with a debugger on your own code combined with an HTTP debugger like Fiddler or Charles should see you clear to getting things working. Just remember to check across as many different browsers as you can
P.S. It can be done; I've done it. I was using YUI with Symfony on the server, but those details are irrelevant: whatever you're using is doing it that way.
Leave a comment:
-
Giving up on the image display
It would have been nice, but not really necessary. The submit button takes them to a page that displays what they've just entered anyway. And if users don't know what image they're uploading, that's their lookout!
Leave a comment:
-
This morning started to be 'one of those days', but got better just before noon and I've made progress for the rest of the day.
However, it's taken me all week to manage to put two rows into one of the tables in a database.
Leave a comment:
-
I had to spend Mon-Thurs working at home to get some documents finished.
Came in today, director signed off this weeks time and signed 2 blank t/s for the next fortnight as he is away in the States working.
If I didnt win this week, then the next 2 weeks: no contest!
PZZ
Leave a comment:
-
I would help, but that would be work ...
and I know **** all about asp.net.
Leave a comment:
-
Originally posted by thunderlizard View PostCheers DP.
Problem is basically this: FileUpload control doesn't work in an UpdatePanel, so I'd have to wait for a full page postback so my one-step user-enters-details-and-saves-them idea would be lost.
Brand-spanking new AsyncFileUpload has the opposite problem: it uploads the image quick as you like but doesn't trigger a postback so I can't show it on screen.
Leave a comment:
-
Cheers DP.
Problem is basically this: FileUpload control doesn't work in an UpdatePanel, so I'd have to wait for a full page postback so my one-step user-enters-details-and-saves-them idea would be lost.
Brand-spanking new AsyncFileUpload has the opposite problem: it uploads the image quick as you like but doesn't trigger a postback so I can't show it on screen.
Leave a comment:
-
Originally posted by thunderlizard View PostI have continuted to fail to make an ASP.NET page that does this:
(1) User uploads an image
(2) It immediately appears on the page.
(& yes I have googled it. About 1000 times. All the ideas look plausible but none of them go the whole hog).
Code:<%@ OutputCache Location="None" %>
Leave a comment:
-
-
Originally posted by Diestl View PostAre you gays all alcoholics?
Leave a comment:
-
Originally posted by Diestl View PostAre you guys all alcoholics?
Leave a comment:
-
I have continuted to fail to make an ASP.NET page that does this:
(1) User uploads an image
(2) It immediately appears on the page.
(& yes I have googled it. About 1000 times. All the ideas look plausible but none of them go the whole hog).
Leave a comment:
- Home
- News & Features
- First Timers
- IR35 / S660 / BN66
- Employee Benefit Trusts
- Agency Workers Regulations
- MSC Legislation
- Limited Companies
- Dividends
- Umbrella Company
- VAT / Flat Rate VAT
- Job News & Guides
- Money News & Guides
- Guide to Contracts
- Successful Contracting
- Contracting Overseas
- Contractor Calculators
- MVL
- Contractor Expenses
Advertisers
Contractor Services
CUK News
- Streamline Your Retirement with iSIPP: A Solution for Contractor Pensions Sep 1 09:13
- Making the most of pension lump sums: overview for contractors Sep 1 08:36
- Umbrella company tribunal cases are opening up; are your wages subject to unlawful deductions, too? Aug 31 08:38
- Contractors, relabelling 'labour' as 'services' to appear 'fully contracted out' won't dupe IR35 inspectors Aug 31 08:30
- How often does HMRC check tax returns? Aug 30 08:27
- Work-life balance as an IT contractor: 5 top tips from a tech recruiter Aug 30 08:20
- Autumn Statement 2023 tipped to prioritise mental health, in a boost for UK workplaces Aug 29 08:33
- Final reminder for contractors to respond to the umbrella consultation (closing today) Aug 29 08:09
- Top 5 most in demand cyber security contract roles Aug 25 08:38
- Changes to the right to request flexible working are incoming, but how will contractors be affected? Aug 24 08:25
Leave a comment: