0

I have existing legacy code that is using a standard form.

I would like to in the page init event of the code behind grab a handle to this input type="file" element, and convert it to a .net fileUpload object.

Is this possible? Without rewriting the whole form?

Thanks in advance.

EDIT: Not looking for an example of how to handle the upload processing, just looking for the entry point - how to get a reference to the input type=file and treat it as a .net fileupload object. - Thanks again.

I was thinking along the lines of :

Dim myControl1 as FileUpload = FindControl("myFileElement")

Would this work if I could sort out the casting issue?

3
  • 1
    If you're allowed to add runat='server' and id attributes then this html tag becomes HtmlServer control. Commented Jul 16, 2012 at 14:17
  • you say "without rewriting the whole form" but its just replacing one tag <input type="file" /> for <asp:FileUpload ID="upload" />. I don't see the problem. Commented Jul 16, 2012 at 14:21
  • @JL. if its not a postback, then you won't get the file. Commented Jul 16, 2012 at 14:23

1 Answer 1

3

Would the Files property off the HttpRequest class suffice?

http://msdn.microsoft.com/en-us/library/system.web.httprequest.files.aspx

Sign up to request clarification or add additional context in comments.

1 Comment

@JL. - it is available since .net 1.1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.