Upload file field

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • zamuel
    New Member
    • Sep 2006
    • 42

    #1

    Upload file field

    Hey everybody.

    I have problem with my upload input control. My form contains input controls calendars and check boxes with conditions to show text field. I can do the file selection normally and it will be shown in a text field. However if I after this choose a date from my calendar or check a conditioned check box the chosen upload file disappears from text field. So user has to choose the file again.

    Does anyone know cause or a solution for this problem?
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    I believe that you have a postback problem and may need a Not Page.IsPostBack in the page_load...

    Hope that this helps.

    Comment

    • zamuel
      New Member
      • Sep 2006
      • 42

      #3
      Thanks for the answer. I'm not totally sure if I know what you mean by that. I have following code on the beginning or the page

      private void Page_Load(objec t sender, System.EventArg s e)
      {
      if (!Page.IsPostBa ck)
      {
      //contains strings for opening SQL connection
      }

      All the conditioned controls are separately on their private functions.

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Thought that there may be a problem with postback or viewstate... Is the textbox readonly set to true?

        Comment

        • zamuel
          New Member
          • Sep 2006
          • 42

          #5
          Well, the readonly has to be "False" in every field in page cause user has to be able to edit the contents of the fields. I believe this is not possible with "True" value on readonly. Correct me if I'm wrong.

          Comment

          • kenobewan
            Recognized Expert Specialist
            • Dec 2006
            • 4871

            #6
            Just checking that they were set to false... Try posting relevant code...

            Comment

            • zamuel
              New Member
              • Sep 2006
              • 42

              #7
              Ok, here some code from one of the check boxes which opens text box and causes upload file to disappear.

              private void WoNumberCheckbo x_CheckedChange d(object sender, System.EventArg s e)
              {
              if (WoNumberCheckb ox.Checked==tru e)
              {
              WoNumberTextbox .Visible=true;
              WoNumberLabel.V isible=true;
              }
              else
              {
              WoNumberLabel.V isible=false;
              WoNumberTextbox .Visible=false;
              }
              }

              Functionalities of other checkboxes are similar. I cannot figure that there is something false in code.

              Comment

              • kenobewan
                Recognized Expert Specialist
                • Dec 2006
                • 4871

                #8
                I believe that this function is where you need to make use of the If not page.ispostback . Here is an article that explains why:
                If Not Page.IsPostBack

                Hope that this helps.

                Comment

                • zamuel
                  New Member
                  • Sep 2006
                  • 42

                  #9
                  Thank you for answer kenobewan. The article was really informative. I understand need for 'not Page.IsPostback '. Actually I have placed my db bind dropdown list inside of 'not Page.IsPostback '. The biggest consern however are the check boxes. I have understood that you need 'private void CheckBox_Checke dChanged...' etc. as event handler to check the change and then execute condition, in this case open textbox where user can enter information. I don't know how to do this in 'not Page.IsPostback '.

                  Comment

                  • chazcross
                    New Member
                    • Feb 2007
                    • 31

                    #10
                    Just a tidbit of information

                    When the calender or checkboxes are causing a postback, the file the user has selected is actually being uploaded to the server and the file input textbox cleared.

                    You can work around this by using the MS AJAX Lib and wrapping the calendar , checboxes and relevant controls in an UpdatePanel.
                    AJAX HERE
                    and do a full page submit when all options are selected and file chosen.

                    or force the user to select a file later in the process
                    or even use JS based calander and update the checklists to use JS to hide/show the label instead of a postback

                    Comment

                    • zamuel
                      New Member
                      • Sep 2006
                      • 42

                      #11
                      Thanks for the information chazcross. Actually in my form in doesn't work that way. The form doesn't even know the path of upload folder before the "next" button is pressed. In this phase the file is saved to session which is saved to folder later on.

                      I wonder about this Ajax program. Do you need some additional program installed to server in order to run Ajax supported forms? Just wondering cause in our strict environment it is always hard to get these kinds of administrative tasks through.

                      Comment

                      • chazcross
                        New Member
                        • Feb 2007
                        • 31

                        #12
                        It is a setup program that you install on the server and only works with asp.net 2.0

                        However you can install it on your dev machine and add a reference to the dll file instead. A copy of it will appear in your bin folder, be sure to upload this to your testing/production machine. You will have to update your web.config file, but all the required settings can be found by creating a new asp.net ajax site and copying the settings.

                        Comment

                        Working...