我有一个asp.net(c#)Web应用程序,我正在使用Tabbed界面来显示表单。在Tabbed界面中有4个选项卡在第4个选项卡中我有文件上传控件,当我尝试上传时文件它不带文件它总是显示空值。如何在Tabbed界面上传文件请帮助我。
<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>
代码背后:
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
{
}
}
}