 |
| 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, 11:27 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
No, that is why I used a different type of loop for the example where you loop through the form collection. At that point you are no longer referencing controls, you are referencing a name and value combo. You may be able to do:
Dim fileUp as New HtmlInputFile
fileUp.PostedFile = Request.form("file")
But I doubt this will work.
Why cant you post back to the same page instead of redirecting to a new one? Is this a business requirement? If so why not postback to the same page, process the file, and then do a response.redirect to the new page?
-------------------------
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, 11:32 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
The "For each item" does not solve the problem. Can you suggest a way to get an object of type control using the given architecture?
|
|

October 23rd, 2006, 11:49 AM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
I understand the For each item doesnt solve the problem, as it shouldn't. Posting to another page is not going to provide you with this functionality, even in the days of ASP, you posted back to the same form to facilitate the upload. There may be a way to process the file by posting to another page, but there isn't going to be a way to refrence the calling pages controls, because once you are at the second page, all that page knows is the controls contained within it, not the controls from the previous page.
-------------------------
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, 11:55 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
In order to use the conversion code suggested, the Item type needs to be converted to control. Otherwise, I need an alternative solution because rewriting this application is not an option.
If you have no other suggestions, I will resubmit my question under a new topic to ensure folks don't see the number of replies and think the problem has been resolved when it has not.
Thanks!
|
|

October 23rd, 2006, 12:18 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
I never said the For each item would convert to a control!
This will convert to a control on the same page
For each ctrl as control in pnl1.controls
If TypeOf ctrl Is HtmlInputFile then
Dim fileUp as HtmlInputFile = Ctype(ctrl, HtmlInputFile)
//do processing of file here
End If
next
This will not convert to a control no matter what page it is on
For each item in Request.Form
//Item will contain the NAME of the element
//to get the value you would do Request.Form(item)
Next
You asked for a way to access the fields, that is what I supplied to you, never did i say you could cast to a control doing as such.
Given your architecture, e.g. 1.1 Framework you can not facilitate what you are asking. In 2.0 you can do a cross page postback that allows you to access controls from the previous page. Simply put, .NET 1.1 DOES NOT facilitate this. Your options are to 1)Post back to the same page and convert your controls as previously outlined or 2)Upgrade your framework to 2.0 so that you can use a Cross Page post back.
-------------------------
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, 12:47 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
I beg your pardon, but I do not believe I have ever suggested that you said your code would convert "item" to "control". However, if you'll please remember, my original question was not about accessing controls on a form as you now seem to think, but rather, how to save uploaded files (as the subject line was intended to suggest). While the code you have supplied accesses the controls as expected, it unfortunately does not answer the original question of how to save files identified for upload.
I am merely pursuing the issue of converting "item" to "control" at this point because the only solution you have offered that appears to come close to working results in unusable objects of type "item" and not "control". If you can tell me how to convert type "item" to type "control", then I am interested in pursuing your suggested solution to the upload question further. If you cannot tell me how to do that, or it is not possible to do so given the existing architecture (as you seem to be saying), then the suggested solution does not actually solve my question. I'm sure you'll agree that any code, however well written or heartily defended, is useless if it does not solve the actual problem.
And if it is not possible to solve that problem using your suggested solution, then I should probably stop wasting your time requesting clarification you apparently cannot provide and seek another solution that works. But at no time have I intended to suggest that your "solution" did anything other than what you said it did - it just does not do what I [u]NEED</u>.
Thanks again for trying.
|
|

October 23rd, 2006, 01:01 PM
|
|
Wrox Author
|
|
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
|
|
You can not Cast type Item to a control of any type, it doesn't reference a control it references a key/value pair, in the example of the request.form.
To save a file is rudiementary, but you have to be able to access the properties of an HTML InputFile control as the properties and methods to save a file to your server from a client machine exist in that control.
In .NET 1.1 you are not able to reference the controls, and hence the associated methods/properties, from another page as to use those properties/methods or cast a dynamic control to the correct type. This is a cross page postback and is implemented in .NET 2.0.
You could implement an HTTPModule or Handler that would stream the file to disk for you this, however, isn't the same as posting to another page. This would actually attach itself to the HTTP Pipe and monitor ALL request going over that pipe and when it encountered a multipart form it would then stream you file to disk and then you could simply redirect to a page.
This is a bit difficult to do because you are working at a low level and requires that you parse a raw http request and work with byte values and you would have to setup the Module/Handler to only parse a multipart form and that all other forms should pass unparsed.
-------------------------
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:08 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 428
Thanks: 57
Thanked 2 Times in 2 Posts
|
|
As I've already said, I cannot change the architecture to suit the solution.
Thanks again.
|
|
 |