How to upload a file in asp.net in Tabbed interface control
I have a asp.net(c#) web application in that i am using Tabbed interface to show the forms.In Tabbed interface there are 4 tabs are there in 4th tab i have file upload control,when i try to upload a file it doesn't take the file it always show the null value .How can i upload the file in Tabbed interface please help me.
<cc1:TabPanel runat="server" HeaderText="Documents" ID="TabPanel4">
<triggers>
<asp:PostBackTrigger ControlID="SyncButton" />
</triggers>
<ContentTemplate>
<asp:Button ID="SyncButton" runat="server" Text="Test" />
<table>
<tr>
<td>Documnets</td>
</tr>
<tr>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" /><br />
<br />
</td>
</tr>
<tr>
<td>
<asp:Button ID="btnfupload" runat="server"
CausesValidation="false" Text="Upload File"
OnClick="btnfupload_Click" />
</td>
<td>
<asp:Label ID="lblstatus" runat="server"></asp:Label>
</td>
</tr>
</table>
</ContentTemplate>
</cc1:TabPanel>
Code Behind :
protected void btnfupload_Click(object sender, EventArgs e)
{
try
{
if (FileUpload1.HasFile)
开发者_开发百科 {
if (!Directory.Exists(Server.MapPath("Documents")))
{
Directory.CreateDirectory(MapPath("Documents"));
}
string docment = FileUpload1.PostedFile.FileName;
string path = System.IO.Path.GetFileName(docment);
FileUpload1.PostedFile.SaveAs(Server.MapPath("Documents/") + path);
}
}
catch
{
}
}
}
Use AsyncFileUpload:
精彩评论