先贴代码
void Page_Load(Object S, EventArgs E)
{
if (Session["phone"] == null)
{
Response.Redirect("password.aspx");
}
System.DateTime currentTime=new System.DateTime();
currentTime=System.DateTime.Now;
int ls_year=currentTime.Year ;
int ls_month=currentTime.Month ;
如何将上面代码中的ls_month值 以?的形式传到下面的printbower.aspx?ls_month=ls_month里
void select1_Click(object sender, System.EventArgs e)
{
Response.Redirect("printbower.aspx?ls_month=" + ls_month );
}
void Page_Load(Object S, EventArgs E)
{
if (Session["phone"] == null)
{
Response.Redirect("password.aspx");
}
System.DateTime currentTime=new System.DateTime();
currentTime=System.DateTime.Now;
int ls_year=currentTime.Year ;
int ls_month=currentTime.Month ;
如何将上面代码中的ls_month值 以?的形式传到下面的printbower.aspx?ls_month=ls_month里
void select1_Click(object sender, System.EventArgs e)
{
Response.Redirect("printbower.aspx?ls_month=" + ls_month );
}
void Page_Load(Object S, EventArgs E)
{
if (Session["phone"] == null)
{
Response.Redirect("password.aspx");
}
System.DateTime currentTime=new System.DateTime();
currentTime=System.DateTime.Now;
int ls_year=currentTime.Year ;
ls_month=currentTime.Month ;
}void select1_Click(object sender, System.EventArgs e)
{
Response.Redirect("printbower.aspx?ls_month=" + ls_month );
}
currentTime=System.DateTime.Now;
int ls_year=currentTime.Year ;
int ls_month=currentTime.Month ;
我把这几行放到void Page_Load 上面去,却提示
CS1519: 类、结构或接口成员声明中的标记“=”无效
放加void Page_Load里,在上面加int ls_mont;传过去的值是0 我要的是 currentTime.Month的值,怎么办呀。
{
private int ls_month;
protected void Page_Load(object sender, EventArgs e)
{
System.DateTime currentTime = new System.DateTime();
currentTime = System.DateTime.Now;
int ls_year = currentTime.Year;
ls_month = currentTime.Month;
}
void select1_Click(object sender, System.EventArgs e)
{
Response.Redirect("printbower.aspx?ls_month=" + ls_month);
}}
按照lfl931223的方法报上面的错误
我是放在 <script language="C#" runat=server></script>里的。
{
if (Session["phone"] == null)
{
Response.Redirect("password.aspx");
}
System.DateTime currentTime=new System.DateTime();
currentTime=System.DateTime.Now;
int ls_year=currentTime.Year ;
ViewState["ls_month"]=currentTime.Month ;
}void select1_Click(object sender, System.EventArgs e)
{
Response.Redirect("printbower.aspx?ls_month=" +ViewState["ls_month"].ToString());
}//用ViewState