vs2003 filefield.postedfile
为什么我postfile老是得不到值,点击浏览后,按button按钮,后台postedfile老是得不到值,报未实例化
前台:<INPUT id="upfile" type="file" name="upfile" runat="server">
<asp:Button id="btnImport" runat="server" Text="导入SQL"></asp:Button>
后台一部分: private void btnImport_Click(object sender, System.EventArgs e)
{
if(upfile.PostedFile.ContentLength!=0&&upfile.PostedFile!=null)
{
string fullname=this.upfile.PostedFile.FileName;
string filename=fullname.Substring(fullname.LastIndexOf("\\")+1);
string type =fullname.Substring(fullname.LastIndexOf(".")+1);
#region Web 窗体设计器生成的代码:
private void InitializeComponent()
{
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
注册过了
麻烦高手看看~~