错误提示:
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
namespace duowenjian
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
int i=Convert.ToInt32(Request.QueryString["ss"]);
for(int j=0;j<2;j++)
{
System.Web.UI.HtmlControls.HtmlInputFile ff=new HtmlInputFile();
ff.Attributes.Add("runat","server");
ff.ID="file"+Convert.ToString(j);
this.Page.Controls.Add(ff);}
}// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
System.Web.UI.HtmlControls.HtmlInputFile hi=new HtmlInputFile();
hi=(System.Web.UI.HtmlControls.HtmlInputFile)(Page.FindControl("file0"));
*string a=hi.PostedFile.FileName;*//提示就是这行出的错误
Response.Write(a);
}
}
}
异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。
namespace duowenjian
{
/// <summary>
/// WebForm2 的摘要说明。
/// </summary>
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
int i=Convert.ToInt32(Request.QueryString["ss"]);
for(int j=0;j<2;j++)
{
System.Web.UI.HtmlControls.HtmlInputFile ff=new HtmlInputFile();
ff.Attributes.Add("runat","server");
ff.ID="file"+Convert.ToString(j);
this.Page.Controls.Add(ff);}
}// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button1_Click(object sender, System.EventArgs e)
{
System.Web.UI.HtmlControls.HtmlInputFile hi=new HtmlInputFile();
hi=(System.Web.UI.HtmlControls.HtmlInputFile)(Page.FindControl("file0"));
*string a=hi.PostedFile.FileName;*//提示就是这行出的错误
Response.Write(a);
}
}
}
解决方案 »
- 高分求解!关于mvc1.0示例NerdDinner
- ajax 急。人在等
- Sys未定义
- 我的asp.net程序,以前运行的好好的,现在隔一两天就不能访问,看系统事件日志有如下错误,怎么回事?
- 请教,使用treeview时,如何使节点个数、级数根据情况限定?
- 突然忘记了,.aspx页面如何获得.cs页面中的Session[""]值?
- 高分求,在留言时,自动生成图片验证码,图片上显示验证码,
- 怎么用UrlRewrite实现这个的功能呀。
- 语法错误:“,”运算符前缺少操作数。
- 菜鸟级别数据绑定问题,谢谢!
- 谁能知道这个asp.net程序都用了什么软件?
- ASP.NET 至少有一个参数未被返回值 (HELP)
"
for(int j=0;j<2;j++)
{
System.Web.UI.HtmlControls.HtmlInputFile ff=new HtmlInputFile();
ff.Attributes.Add("runat","server");
ff.ID="file"+Convert.ToString(j);
this.Page.Controls.Add(ff);
}
"
这段代码说生成的 HtmlInputFile 控件已经没有
<input type="file" id="uploadFile" runat="server" class="flat" NAME="uploadFile" style="WIDTH:100%">
要重写