public class Class1
{
int myInt; public int GetInt
{
get { return myInt; }
}
public int SetInt
{
set { myInt = value; }
}
}以上是类文件.
************************************************************************ protected void Button1_Click(object sender, EventArgs e)
{
Class1 c1 = new Class1();
c1.SetInt = 100;
Response.Redirect("WebForm2.aspx");
}以上是WebForm1.aspx 的文件.
********************************************* protected void Page_Load(object sender, EventArgs e)
{
Class1 c2 = new Class1();
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alt1", "alert('" + c2 .GetInt + "');", true);
}以上是WebForm2.aspx 的文件.
为什么取到c2 .GetInt是0, 错在哪里啊?
{
int myInt; public int GetInt
{
get { return myInt; }
}
public int SetInt
{
set { myInt = value; }
}
}以上是类文件.
************************************************************************ protected void Button1_Click(object sender, EventArgs e)
{
Class1 c1 = new Class1();
c1.SetInt = 100;
Response.Redirect("WebForm2.aspx");
}以上是WebForm1.aspx 的文件.
********************************************* protected void Page_Load(object sender, EventArgs e)
{
Class1 c2 = new Class1();
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alt1", "alert('" + c2 .GetInt + "');", true);
}以上是WebForm2.aspx 的文件.
为什么取到c2 .GetInt是0, 错在哪里啊?
解决方案 »
- 根目录下能实现URL重写,二级目录上不能实现URL重写,这是什么原因?
- 在FF下如何使fileupload控件不显示地址栏
- 如何用Visual Studio.net 2005创建网络应用程序
- asp.net中button的onclick如何调用函数并同时传参?
- -----小小的一个图表控件,不成敬意,欢迎大家提出宝贵意见,
- *********如果数据库里的某个表在一个小时里没有数据资料转入,那么自动发送EMAIL给某个人的功能怎么实现?
- 奇怪的正则表达式问题,空格?
- SESSION消失问题
- 文件上传
- 我把TEXTBOX属性TEXTMODE设置为PASSWORD后,就不能给这个TEXTBOX赋值了吗?
- 请问首页怎么绑定多个栏目页
- Gridview HyperLinkField字段的NavigateUrl怎么带参数?
{
public static int myInt = 0; public static int GetInt
{
get { return myInt; }
}
public static int SetInt
{
set { myInt = value; }
}
} 这样直接调用,不用实例化了,试试。
protected void Button1_Click(object sender, EventArgs e)
{
Class1.SetInt = 100;
Response.Redirect("WebForm2.aspx");
}
WebForm2.aspx
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(Class1.GetInt);
}