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.

3
  • 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. Commented Feb 10, 2012 at 0: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. Commented Feb 10, 2012 at 1:01
  • 1
    This is what XHR (or "Ajax") is for. Simply call a server side handler from the JS. Commented Feb 10, 2012 at 1:02

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.