public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string post1 = Request.Form["title"].ToString();
string post2 = Request.Form["context"].ToString();
TextBox1.Text = post1;
TextBox2.Text = post2;
}
}
这程序我输进去有时可以运行有时不行,不行时提示未将对象引用设置到对象的实例。
也不需要空间引用,也不需要什么new ,为什么书上都这么写,但实际不能运行?
{
protected void Page_Load(object sender, EventArgs e)
{
string post1 = Request.Form["title"].ToString();
string post2 = Request.Form["context"].ToString();
TextBox1.Text = post1;
TextBox2.Text = post2;
}
}
这程序我输进去有时可以运行有时不行,不行时提示未将对象引用设置到对象的实例。
也不需要空间引用,也不需要什么new ,为什么书上都这么写,但实际不能运行?
if(Request.Form["title"]!=null)
string post1 = Request.Form["title"].ToString();if(Request.Form["context"]!=null)
string post2 = Request.Form["context"].ToString();
{
string post1 = Request.Form["year"].ToString();
}
if(Request.Form["month"]!=null)
{
string post2 =Request.Form["month"].ToString();
}
if(Request.Form["day"]!=null)
{
string post3 =Request.Form["day"].ToString();
}
if (Request.Form["hour"] != null)
{
string post4 = Request.Form["hour"].ToString();
}
string hebing;
hebing = post1 + post2 + post3 + post4;
TextBox4.Text = hebing;
改成这样的话就hebing = post1 + post2 + post3 + post4;说找不到post1了
string post1="";
if(Request.Form["year"]!=null)
{
post1= Request.Form["year"].ToString();
} string post2="";
if(Request.Form["month"]!=null)
{
post2 =Request.Form["month"].ToString();
} string post3="";
if(Request.Form["day"]!=null)
{
post3 =Request.Form["day"].ToString();
}
string post4="";
if (Request.Form["hour"] != null)
{
post4 = Request.Form["hour"].ToString();
}
string hebing;
hebing = post1 + post2 + post3 + post4;
TextBox4.Text = hebing;