2

aspx:

<asp:UpdatePanel ID="updtEmpMaster" runat="server">
<ContentTemplate>

<asp:FileUpload ID="tPhoto" Height="23px" runat="server" />
<asp:Button ID="Button1" CssClass="btnImage" runat="server" Text="OK" 
onclick="Button1_Click" />

</ContentTemplate>
</asp:UpdatePanel>  

aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
{
    if (tPhoto.HasFile)
    {
    …………………..;
    }
    else
    {
        …………………..;
    }
}   

Here if condition is failing even after an image file is uploaded. No problem when using without UpdatePanel. UpdatePanel is also needed in current scenario. Any way I can have solution with UpdatePanel.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ajendra Prasad
  • 299
  • 1
  • 8
  • 22
  • Look at this page http://stackoverflow.com/questions/11894132/auto-change-keyboard-language-using-javascript-not-work-without-ie – Learning Sep 06 '12 at 11:55

2 Answers2

3

Apply this code line to solve your problem, to find the fileuploader into the update panel :

protected void Page_Load(object sender, EventArgs e)
{
    Page.Form.Attributes.Add("enctype", "multipart/form-data");
}
Raul Rene
  • 10,014
  • 9
  • 53
  • 75
Vikas4u
  • 31
  • 2
1

As per link http://forums.asp.net/p/1105208/1689084.aspx

This problem is somewhat well documented, the update panel is listed as not working with certain controls.

File upload, and tree view being 2 of the biggies.

IN any case, one solution is available on code project:

http://www.codeproject.com/useritems/simpleajaxupload.asp

if you look around the forums and google, you can read more about the problem if your interested, but the code project solution should get you started.

Imran Rizvi
  • 7,331
  • 11
  • 57
  • 101