我正在使用monoX CMS并尝试上传文件。但是文件上传的hasFile始终为false。我在.aspx页面中使用服务器脚本。这是我的代码。
<script runat="server">
protected void btn_click_me(object sender, EventArgs e)
{
dbOperations dbObj = new dbOperations();
if (selected_file.HasFile)
{
string title = txt_file_title.Value.ToString();
int f_type = Convert.ToInt32(dd_file_type.Value);
dbObj.CreateSubmission(title, f_type, selected_file.PostedFile);
}
}
</script>
我的Html代码是:
<MonoX:StyledButton ID="btnSubmit" CommandName="submit" OnClick="btn_click_me" runat="server" CausesValidation="true" ValidationGroup="validate_submission" Text='Submit'>
</MonoX:StyledButton>
在firebug中看到的表格标签是:
<form id="aspnetForm" enctype="multipart/form-data" style="height: 100%" onsubmit="javascript:return WebForm_OnSubmit();" action="/MyFolder/Submissions.aspx" method="post" name="aspnetForm">
渲染文件标记为:
<input type="file" id="ctl00_ctl00_ctl01_ctl00_cp_cp_cp_cp_selected_file" name="ctl00$ctl00$ctl01$ctl00$cp$cp$cp$cp$selected_file">