title: showing thumbnail after image upload
body: <p>I'm working on an image gallery, where the user can upload images. The uploaded image is converted to a thumbnail and put in a specific folder for thumbnails, and the original image is put in a folder for full size images.</p>
  
  <p>In Page_Load method in code behind i'm getting the thumbnails from the folder and bind them to the Repeater that i'm using, which means that all images in that folder are displayed when the page is loaded.</p>
  
  <p>When a user chooses to upload an image the UploadButton_Click function is called, the file is processed and then displayed in full size. Everything works fine accept that the uploaded image thumbnail isn't shown directly after it's uploaded. To show it you must reload the page, so that Page_Load is loaded again.</p>
  
  <p>Of course, an east way of solving this is to put the code for fetching the thumbnails and binding the Repeater control even in the UploadButton_Click function, but that is DRY which I don't like.</p>
  
  <p>Is there any better, more elegant way of solving this?</p>
  
  <p>code behind:</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e) {
      var directory = new DirectoryInfo(Gallery.PhysicalApplicationPath + "/Images");
      var theFiles = directory.GetFiles();
  
      ImageRepeater.DataSource = theFiles;
      ImageRepeater.DataBind();
  
      var dataName = Request.QueryString["name"];
  
      if (dataName != null) {
          fullSizeImage.ImageUrl = "Images/" + dataName;
      }
   }
  
  protected void UploadButton_Click1(object sender, EventArgs e) {
      if (Page.IsValid) {
          if (ImageUpload.HasFile) {
              var content = ImageUpload.FileContent;
              var name = ImageUpload.FileName;
              var image = Gallery.SaveImage(content, name);
  
              fullSizeImage.ImageUrl = "Images/" + image;
          }
      }
  }
  </code></pre>