skeletalmonkey
skeletalmonkey

Reputation: 736

Get FileUpload value onchange in ASP.NET

I have a form of properties that populates itself with a range of defaults, and if you chose to edit the defaults, it then posts back to the server and executes a function that updates the properties that are dependent on the one you changed, then refreshes the form. Each property is an template defined in Property.ascx

My problem is that I don't know how to get my file uploads to perform this action.

<asp:TextBox runat="server" ID="txtValue" AutoPostBack="True" ontextchanged="txtUpdate" />

at which point it calls the function in Property.ascx.cs

protected void txtUpdate(object sender, EventArgs e)

in which I can pull the value from this.txtValue.Text

What is the asp:FileUpload version of ontextchanged ?

I know that onchange will allow client side execution of javascript, but what I need is server side.

Upvotes: 1

Views: 4113

Answers (1)

ChrisLively
ChrisLively

Reputation: 88072

This simply isn't possible due to security restraints.

Browsers have locked down the file upload capabilities such that you cannot automatically upload files using this mechanism.

Also note that unless your other postbacks save the file as part of their process, you will lose their file selection if they did that first.

Upvotes: 2

Related Questions