日期:2014-05-18  浏览次数:20551 次

全局变量不可以用Request.QueryString?

如题..那么我想用全局变量获取url的参数怎么办啊?

public   partial   class   T1   :   System.Web.UI.Page
{
        public   string   a   =   Request.QueryString[ "a "]
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
        }
 
}

这样是报错的

------解决方案--------------------
public partial class T1 : System.Web.UI.Page
{
public string a;
protected void Page_Load(object sender, EventArgs e)
{
a = Request.QueryString[ "a "];
}

}
------解决方案--------------------
public partial class T1 : System.Web.UI.Page
{
public string a= " ";
protected void Page_Load(object sender, EventArgs e)
{
a= Request.QueryString[ "a "]
}

}

------解决方案--------------------
public partial class T1 : System.Web.UI.Page
{
public string a= " ";
protected void Page_Load(object sender, EventArgs e)
{
a=Request.QueryString[ "a "]

}

}
------解决方案--------------------
只要不写到!ispostback里就行