请教asp.net的一个基础性的给变量赋值的问题
usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Web;usingSys...
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Info : System.Web.UI.Page
{
string loginName = "";
string z = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
z = "123";
loginName = Session["loginName"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(loginName);
Response.Write("====="+ z);
}
}
web程序,如上面的代码所示,这样在按钮控件中获取不到在Page_Load中给变量赋的值吗?为什么在按钮控件输出的都是空啊? 展开
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Info : System.Web.UI.Page
{
string loginName = "";
string z = "";
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
z = "123";
loginName = Session["loginName"].ToString();
}
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write(loginName);
Response.Write("====="+ z);
}
}
web程序,如上面的代码所示,这样在按钮控件中获取不到在Page_Load中给变量赋的值吗?为什么在按钮控件输出的都是空啊? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询