请看这段代码:
public class WebForm5 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
public string str;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private void Button1_Click(object sender, System.EventArgs e)
{
str="abc";
} private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text=str;
}
}
当我点Button1时str的值为“abc”,当我点Button2时str的值就变成"null"了,这是怎么回事呀,怎么解决这个问题呢?
public class WebForm5 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
public string str;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
}
private void Button1_Click(object sender, System.EventArgs e)
{
str="abc";
} private void Button2_Click(object sender, System.EventArgs e)
{
TextBox1.Text=str;
}
}
当我点Button1时str的值为“abc”,当我点Button2时str的值就变成"null"了,这是怎么回事呀,怎么解决这个问题呢?
解决方案 »
- asp.net多表查询返回的值用什么接收
- TextBox 宽度
- 如何让guest用户不能下载东西
- 自定义控件 的id .net 不能识别
- 如何开发自定义控件!?
- 如何定义一个函数,可是使所有页面的vb文件都能使用?新手入门,请大家指教,100分相送
- var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")这个对象怎么样.
- 【急】生成数据集装载至RadioButtonList,状态不能保存!
- 急求IE5.0下可以用的html文本编辑器,请大家帮忙,急用
- 怪问题!!
- 如何实现在DropDownList里添加、删除、修改内容?
- asp.net2 c# GRIDVIEW的问题(高手看一看,我想问题应该很典型)
=========>
public static string str;
重新执行Page_Load,最后在执行Button2_Click力的代码。