1

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.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
skeletalmonkey
  • 726
  • 1
  • 10
  • 20
  • You're refreshing the page every time a textbox loses focus? That must be horrible to use. I suggest you get rid of "autopostbacks" and just do the entire thing in JS. – Matti Virkkunen Feb 10 '12 at 00:54
  • The forms are only 4-8 items long, and generally users will only ever need to edit one or 2 of the defaults. Also the updates need to query SQL meaning I have to do it server side. – skeletalmonkey Feb 10 '12 at 01:01
  • 1
    This is what XHR (or "Ajax") is for. Simply call a server side handler from the JS. – Matti Virkkunen Feb 10 '12 at 01:02

1 Answers1

2

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.

Community
  • 1
  • 1
NotMe
  • 87,343
  • 27
  • 171
  • 245