views:

61

answers:

1

Hi,

I'm writing an intranet ASP.NET page using VB.NET. I've run into a particularly nasty problem dealing with handling file uploads. I'll do my best to explain the problem, and perhaps someone can help.

My problem is almost a duplicate of this one, or this one, except (other than the filename) I don't care about sending the file to the server until the other data has been reviewed.

Here's the situation:

Joe Q. Dataentry inputs some data into several fields. The first 3 are drop down, and when he changes the selection, a postback event is fired that queries a database for valid entries for the other drop down selections. After selecting the values, he inputs some other data, chooses a file to accompany the data and clicks the "Update" button. When he hits the button, it fires a postback event that sends the current data to the server to be validated. The data will create a change in the database, so he is presented with a view of the current state, and what it will look like when his changes are made. He can now either confirm or cancel the operation for whatever reason.

Part of the data he will see involves the extension of the file which may be a PDF, or could also be some image file or other document.

Now here's where my problem is - on each postback event, the fileupload dialog is cleared. I was getting around it by creating a temporary file on the first postback and then renaming if he clicks OK or deleting on Cancel... but I need to do a variety of things, based on the previous state of data and the filename. I've tried to keep some session variables to retain the filename, and that works OK for just renaming the file, but for what I need to do it gets unwieldy.

What I want to do is be able to have the postback event to present the changes, and then when the user clicks "OK", submit the file. Is there any possible way to do that?

One of my thoughts was to do some of the validation client-side (I'm already re-validating server side so I'm not too worried about data security there), but I don't know how I could get the information from the database query.

Thanks for any help, and reading my slightly convoluted story/situation!


EDIT:

It appears that what I want to do is prevent a certain button from firing a full postback. Is there any way to do that?

EDIT II:

I have an update panel on the page already - is there any way for the button to only post what's in the update panel?

+1  A: 

What you might want to do is place your drop-downs inside of an ASP.NET AJAX UpdatePanel, and keep your file upload control out of that.

Your update panel will do the post backs and allow your validation logic to happen without submitting the file, then when you hit your final "Save" button (which is also outside of your UpdatePanel) the entire form will be submitted back and you can work with your file then.

Coding Gorilla
The main problem here is that I *need* to show some tables to the user (currently in the form of a popup div) based on the data in the form so that they can see what changes will take place before they confirm their entry.
Wayne Werner
You could still do that, you can have an table that is inside the UpdatePanel but hidden (i.e. Visible = false). In your UpdatePanel post code, you can flip that table to visible and fill it with the results you need.
Coding Gorilla