yolip
April 14th, 2009, 08:21 AM
Hi, I am trying to use the updatepanel in my form, but when i use the below code, the FileUpload1 control will never get any value. However, if i remove the updatepanel then it will works. So just wondering where is the trick of using updatepanel? Please help
C# code:
protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
if (FileUpLoad1.HasFile)
{
FileUpLoad1.SaveAs( Server.MapPath("~/Photos/") + FileUpLoad1.FileName);
}
}
HTML code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upUploader" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width:800px;">
<tr>
<td>
Add Photo<br /> <asp:FileUpload ID="FileUpLoad1" runat="server" Width="300px" />
</td>
</tr>
<tr>
<td>
Caption<br /><asp:TextBox ID="txtCaption" runat="server" Width="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="btnSubmit" runat="server"
ImageUrl="~/images/btnSubmit.gif" onclick="btnSubmit_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
C# code:
protected void btnSubmit_Click(object sender, ImageClickEventArgs e)
{
if (FileUpLoad1.HasFile)
{
FileUpLoad1.SaveAs( Server.MapPath("~/Photos/") + FileUpLoad1.FileName);
}
}
HTML code:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="upUploader" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table style="width:800px;">
<tr>
<td>
Add Photo<br /> <asp:FileUpload ID="FileUpLoad1" runat="server" Width="300px" />
</td>
</tr>
<tr>
<td>
Caption<br /><asp:TextBox ID="txtCaption" runat="server" Width="300px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<asp:ImageButton ID="btnSubmit" runat="server"
ImageUrl="~/images/btnSubmit.gif" onclick="btnSubmit_Click" />
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>