title: FileUpload uploads twice
body: <p>This is what I'm trying to do. When an image is uploaded using Ajax AsyncFilepload, it also shows the image in the Image Control. Since, the upload is asynchronous, though the image uploads fine, it doesnt show in the image Control. So, following a suggestion, added the JS function. It wrks fine now, but just that the C# code fires twice, because of the postback and hence every Image is uploaded twice.</p>
  
  <p>Also, why is the ViewState becoming null, the second time. This page uses a master.</p>
  
  <p><strong>JS :</strong></p>
  
  <pre><code>function UpdateImage()
  {
    __doPostBack("UpdatePanel2","");
  }
  </code></pre>
  
  <p><strong>ASPX :</strong></p>
  
  <pre><code>&lt;asp:AsyncFileUpload ID="fu" runat="server" 
   OnClientUploadComplete="UpdateImage" OnUploadedComplete="fu_UploadedComplete"/&gt;
  
  &lt;asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"&gt;
   &lt;ContentTemplate&gt;
    &lt;asp:Image runat="server" ID="img"/&gt;
   &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p><strong>C# :</strong></p>
  
  <pre><code>protected void fu_UploadedComplete(object sender, 
                                   AjaxControlToolKit.AsyncFileUploadEventArgs e)
  {
     if(fu.HasFile &amp;&amp; ViewState["vMap"] == null)
      {
        string sNew = getRandomNumber().ToString() + fu.FileName;
        ViewState["vMap"] = sNew;
        sNew = "~/Temp/"+sNew;
        fu.SaveAs(Server.MapPath(sNew));
        img.ImageUrl = sNew;
        UpdatePanel.Update();
      }
  }
  </code></pre>