web中的全局变量的使用

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using SqlConnect;

public class comman
{
    public static bool check1 = true;
    public static bool check2 = true;
    public static bool check3 = true;
}

public partial class Admin_MessageManage : System.Web.UI.Page
{

  void paixu(string aa,out bool check,bool ch)//将comman类中的变量以out的形式传进去,同时并将他的值传进去,以便在方法中对全局变量的值进行操作
    {
        check = ch;
        if (lb_currentpage.Text != "0")
        {
            int max = 10;
            int start = (int.Parse(lb_currentpage.Text) - 1) * max;
            if (check)
            {
                bd(start, max, " order by " + aa + " desc");
                check = false;
            }
            else
            {
                bd(start, max, " order by " + aa + " asc");
                check = true;
            }
        }
    }

  protected void Link_sex_Click(object sender, EventArgs e)
    {
        paixu("sex",out comman.check1,comman.check1);
    }

   protected void Link_date_Click(object sender, EventArgs e)
    {
        paixu("date",out comman.check2,comman.check2);
    }

}

posted @ 2012-10-11 21:48  斗天!  阅读(398)  评论(0编辑  收藏  举报