. .
I’m trying to set up an <asp:FileUpload> object to fire on the client side after I click “Browse” and select a file. (Specifically, I want it to return the name of the file that was selected.)
However, I’m having a hard time trying to find the correct method. None of the server-side methods do what I want (and I’d prefer it to fire on the client-side, anyway), and none of the various combinations of client-side methods (onclick, onchange, etc.) seem to work.
Ideas, anyone?
Thanks!
Edit: I think I may have answered my own question. I ended up abandoning the ASP.NET <asp:FileUpload> tool, and simply used the lower-tech <input type=”file”> instead. Methods seem to work just fine with that.
Edit #2: Nothing doing. That works fine on the client side, but then I have the problem of trying to save the file on the server side. I guess it’s back to Square 1.
Edit #3: I think this is the final answer. I changed it back to <asp:FileUpload ID=”FileUploader”> and added a FileUploader.Attributes.Add to the Page_Load. It sees that and fires with no problem. Of course, now I’m getting an “Object expected” error (because the script it’s calling comes after the code — ah, the joys of dealing with JavaScript order).
As I mentioned in my edit yesterday — the answer ended up being to add the attributes in the Page_Load. Let’s say my FileUpload ID is “FileUploader”. I added FileUploader.Attributes.Add(“onchange”,”CallThisCode();”). That did the trick!
Now I just need to figure out how to make it call the JavaScript correctly — a different issue altogether! 🙂