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