protected void Page_Load(object sender, EventArgs e)
{ Response.Write(Label1.Text);
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "hello world";
}运行时点击一次button1 后label1即变为helloworld 而 Response.Write(Label1.Text)显示的却是label1
再点击一次才显示helloworld 不解中 难道点击button时先postback再执行事件 那label得值怎么变了
{ Response.Write(Label1.Text);
}
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "hello world";
}运行时点击一次button1 后label1即变为helloworld 而 Response.Write(Label1.Text)显示的却是label1
再点击一次才显示helloworld 不解中 难道点击button时先postback再执行事件 那label得值怎么变了
解决方案 »
- 更改图片路径
- asp.net怎么做邮件发送啊?做好了给100分(急)
- 360度全景flash如何制作
- 强烈要求管理员进来看看,押宝游戏成了黑心贼的天下,管理员还管不管了~~~~~~~~~~~~~~~~~~~~
- URLRewriter问题
- Asp.Net AjAx 的问题
- 超简单的问题,有关Graphics背景的,谁先抢到分就给认哈!!!!!!!!!!!
- 求学习软件asp.net c#
- aspx,cs.dll之间的问题?
- 如何配制IIS6.0?客户端访问我的机子会弹出窗体让输入用户名和密码。Web.config中使用的是Form验证。
- 用程序实现Mysql数据导入
- 在Windows7下用VS2010写ASP.Net如何本地测试自己写的网站
{
if (!IsPostBack)
{
Response.Write(Label1.Text);
}
}
{
Response.Write(Label1.Text);}
页面回传
IsPostBack是Page类有一个bool类型的属性,用来判断针对当前Form的请求是第一次还是非第一次请求。当IsPostBack=true时表示非第一次请求
正解这个LZ要看下 页面的生命周期。。就明白了。。页面事件的执行顺序。
Page_Load 事件 在 Button1_Click之前执行呢。。
Page_Load 执行的时候 你那个 输出的是你那个 lable 的默认值 lable1
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Response.Write(Label1.Text);
}
}
{
if (!IsPostBack)
{
Response.Write(Label1.Text);
}
}