Faraz Shah Khan

MCP, MCAD.Net, MCSD.Net, MCTS-Win, MCTS-Web, MCPD-Web

File Upload control AJAX effect

Since long I was wondering on how I will be able to use FileUpload control inside UpdatePanel and I am sure there will be lot of other people who were expecting the same to be working. I found an intersting video article by Joe Stagner in which he described how to use the FileUpload control inside iframe to give some AJAX effect. You can find this video here. http://www.asp.net/learn/videos/video-254.aspx

Comments

efe said:

sad

# September 24, 2008 11:05 PM

Reshmi said:

you can use FileUpload control inside UpdatePanel .

Check the code below

<asp:UpdatePanel ID="upnlMain" runat="server" UpdateMode="Conditional">

           <Triggers >

           <asp:PostBackTrigger ControlID="btnSubmit" />

           </Triggers>

               <ContentTemplate>

              <table>

                  <tr>

                   <td>

 <asp:Image ID="imgPhoto"  runat="server" AlternateText="Photo" Height="100px" Width="100px"

BackColor="Silver" BorderColor="Black" BorderStyle="Solid" ImageAlign="Middle" />

</td>

</tr>

<tr>

<td>

<asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClick="btnSubmit_Click"/>

</td>

</tr>

in Code behind file

 protected void btnSubmit_Click(object sender, EventArgs e)

   {

       try

       {

if (FilePhoto.HasFile)

           {

 HttpPostedFile img= FilePhoto.PostedFile;

/* code as per your requirement */

}

       }

       catch (Exception ex)

       {

          throw new Exception(ex.Message.ToString());

       }

   }  

# February 6, 2009 4:58 AM
Leave a Comment

(required) 

(required) 

(optional)

(required)