 |
| ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

October 23rd, 2006, 01:10 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
File Upload Question Remains Unaswered
Despite the number of replies to my question about uploading files, the question remains unanswered. Here it is again with more information to halp avoid going down the same dead ends already encountered:
[u]Overview:</u>
I have an ASP.NET class that generates HTML code to display a dynamically created page. The .ASPX file associated with the page is [u]completely</u> empty - it contains [u]no hard-coded controls of any kind</u>, cannot contain any hard-coded controls, and all the HTML used to display the dynamic page must be entirely generated by the class. Additionally, the ASP.NET page that generates the dynamic page does not get the post back when the page is submitted - the action redirects it to another page for evaluation.
[u]The problem:</u>
We now need the dynamically generated page to allow users to attach documents to be uploaded to our server. The dynamically generated form may contain 0, 1, or many "<intput type=file>" tags depending on the form generated. So, the ASP.NET code that needs to upload identified attachments will not know how many attachments there are.
So, how can the .NET page that gets the posted page determine how many file tags there are and automatically upload the attachments within the limitations of the existing architecture?
DParsons recommended looping through dynamically created controls using:
For each control in me.controls
...but this does not work becuase it is listing the action page's controls and not the posted page's controls. If somebody can provide the reference necessary to obtain the posted page's controls as objects of the type of "control", and not as "item", I can probably get to where I need to be. Alternatively, the ability to translate objects of type "item" to type "control" might also suffice. A third possibility, as I mentioned in the other thread, is that I know the IDs of the file tags and can reference them directly, if I could just get a "control" type reference in order to convert the control to type HtmlInputFile.
And if there's yet another way to do this, I'd appreciate hearing about it. Thanks!
|
|

October 23rd, 2006, 01:28 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
The closest you will get to this in your arch type is Server.Transfer (however, after execution, control returns to the original page) this explains it:
http://aspnet.4guysfromrolla.com/articles/050802-1.aspx
Post Cross-Reference:
http://p2p.wrox.com/topic.asp?TOPIC_ID=51320
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 23rd, 2006, 01:58 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
Unless I'm misreading the suggested pages, the receiving form in the example references the datagrid via a property defined in the sending form's ASP code. While that could work when the field is referenced using its definition on the sending ASP page code, the file tag to be referenced in this instance does not exist at compilation time - remember, this is a dynamically created form that exists only at run time. I believe any attempt to reference a non-existent field in a property of the sending form will cause the same compilation error it would get in the receiving form.
Was there something else about this solution that you think might answer the question despite this minor issue? If so, could you just point me to the line of code or spcific text on these pages that would resolve this rather than sending me links to yet another web site that vaguely resembles my issue? Otherwise this appears another dead end that is likely to discourage others from responding to my question and I will have to repost my question a third time.
|
|

October 23rd, 2006, 02:17 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
That page was not meant to be your silver bullet, it was only meant to show you how to facilitate Server.Transfer. Searching both google and the MSDN for your problem only returns information relevant to single page postbacks, but I figured that would be a good example to demonstrate .transfer.
Just a heads up, most of the regular posters will read through posts, even though there are responses; reposting your question doesn't increase or decrease your chances of getting further input from another member.
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 23rd, 2006, 03:32 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
I'm sorry, but I simply do not understand what using server.transfer has to do with the question of uploading files? Other than occurring on the server, it does not appear to me to differ from the result of the form action attribute, which is how the page is being cross-submitted currently. This only appears to be another digression into areas that do not address the original question.
Let's try it again. Does anybody have working code ( VB or VBScript) that demonstrates how to upload files in classic .NET? I don't need a lecture on how it works, how it should work, white papers, or more suggestions that I change the approach - I need working code that doesn't require I rewrite the application.
Anybody?
|
|

October 23rd, 2006, 04:38 PM
|
|
Registered User
|
|
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
A post spaning 2 threads very nice indeed!! Anyway I read this (pretty much) all the way through. I agree with Ron that dparsons didn't read the post that well and lead them on a round about, I think he is right about not being able to the controls from the first page on a second page??
Anywhoo, you really wouldn't have to re-write your app if you just put a Sub on the first page processed your files and sent the user to a different page, you would really only change where you put the code to handle the uploade, not the app itself.
Good luck.
|
|

October 24th, 2006, 07:38 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
I tried your suggestion, but it was unfortunately no more successful in resolving the problem. I put breakpoints in the form_load for the creating page and it doesn't run on form submission. Action= otherpage on the dynamic form appears to be redirecting the submitted page before it can post back to the sending page. So, putting the code there would do no good in this instance.
Thanks anyway.
|
|

October 24th, 2006, 08:16 AM
|
|
Registered User
|
|
Join Date: Oct 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
http://www.aspupload.com/
That does what you want.
|
|

October 24th, 2006, 08:18 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
Here the below link is a component that you have to buy and I used it extensively in Classic ASP; it allows for posting files from one page to another and it determines how many files are being uploaded.
http://www.aspupload.com/
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|

October 24th, 2006, 08:19 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
LOL you beat me to it JustAnotherCoder!
-------------------------
I will only tell you how to do it, not do it for you.
Unless, of course, you want to hire me to do work for you.
^^Thats my signature
|
|
 |