locked
FileUpload and Wizard Steps RRS feed

  • Question

  • User2055357364 posted
    This is an ASP.NET / VB.NET question.

    I have a registration page what was created using a Wizard. There are currently 5 steps to my wizard.

    Users enter info using a series of textboxes and dropdownlists in steps 1 and 2. In step 4, the info is saved to the DB.

    Recently, I included the option to upload a picture in step 2 of the wizard. When it comes time to save to the DB in step 4, I find that the 'pic' variable being populated from the FileUpload control is empty. Apparently, no file is being posted. Here's the error message:

    Object reference not set to an instance of an object.

    The code I have written works perfectly well outside the wizard. What is it I am missing that prevents me from properly processing uploaded files?
    Sunday, February 18, 2007 4:27 PM

Answers

  • User1672132137 posted

    what you can do once the user selects a file from the fileupload in the second step, save the FileUpload control into the session and then at the final step, you can still reference it from the session state.

    in step two put:

    Session["FileUpload"] = FileUpload1;

    in step 4 use

    FileUpload myfile = (FileUpload)Session["FileUpload"];

    Now you can access the fileupload properties and methods using myfile

    myfile.PostedFile.SaveAs(Urpath);

    HC

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, February 19, 2007 3:19 AM