不知道错在哪里?请指教!
phg 2004-12-18 04:26:17 程序片断:
public class index : System.Web.UI.Page
{
private const int pNUM=11;
protected System.Web.UI.WebControls.Label delmessage;
protected System.Web.UI.WebControls.HyperLink upLive;
protected System.Web.UI.WebControls.DataList policyClass;
protected System.Web.UI.WebControls.Button deletebtn;
protected System.Web.UI.WebControls.Button appendbtn;
protected System.Data.SqlClient.SqlDataReader dr;
protected phg db;
protected CheckUser check;
protected string sqlstr;
private void Page_Load(object sender, System.EventArgs e){
Response.Expires = 0;
Response.AddHeader("pragma","no-cache");
Response.AddHeader("cache-control","private");
Response.CacheControl = "no-cache";
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
try{
if(Convert.ToBoolean(Session["valiUser"].ToString())){
Response.Redirect("../../ValiUser/login.aspx");
}
if(Regex.IsMatch(Session["purviewL"].ToString(),pNUM.ToString()+"A",RegexOptions.IgnoreCase) & Regex.IsMatch(Session["purview"].ToString(),pNUM.ToString()+"B",RegexOptions.IgnoreCase)){
Response.Redirect("../../opreaterror.aspx");
}
}catch(Exception eg){
delmessage.Text+=eg.Message;
//Response.Redirect("../../ValiUser/login.aspx");
}
BindListToSource();
}
在前面已经用using System.Text.RegularExpressions;把Regex类导入了
但是总是出错,错误提示是“未将对象引用设置到对象的实例。”
错在这句:
if(Regex.IsMatch(Session["purviewL"].ToString(),pNUM.ToString()+"A",RegexOptions.IgnoreCase) & Regex.IsMatch(Session["purview"].ToString(),pNUM.ToString()+"B",RegexOptions.IgnoreCase)){