我在asp.net应用程序中使用UploadFile时遇到问题:
<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/Espace/Sous.master" CodeBehind="Info.aspx.cs" Inherits="Espace.Info1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ChildContent2" runat="server">
<div class="span9">
<div class="divpere">
<div class="divfille1">
<label>Télécharger votre CV (*)</label></div>
<div class="divfille2">
<asp:FileUpload ID="cvpath" runat="server" />
<asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="cvpath" Text="Champ obligatoire" ForeColor="Red"></asp:RequiredFieldValidator>
</div>
</div>
<div class="divpere">
<div class="divfille1"></div>
<div class="divfille2">
<asp:Button Style="color: #FFFFFF; background-color: #B81C22; margin-left: 73%" runat="server" ID="btn" Text="Modifier mes informations" OnClick="Valider" />
</div>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function () {
$("input[id*='pick']").datepicker({ dateFormat: 'dd/mm/yy' });
});
</script>
</asp:Content>
在背后的代码中:
protected void Valider(object sender, System.EventArgs e)
{
if (this.cvpath.HasFile)
{
}
}
问题是this.cvpath.HasFile
总是需要 false 即使我选择了一个文件。