public string pd_price_show()
{
string result=null;
//HttpCookie cookie=Request.Cookies["mycookie"];
if(Request.Cookies["mycookie"]!=null) 
{
HttpCookie cookie=Request.Cookies["mycookie"];
if(cookie.Values["userflag"].ToString()=="1")
{
result="1";
}
else
{
if(cookie.Values["userflag"].ToString()=="3")
{
result="3";
}
}
}
else
{
result="2";
}
return result;
}
-------------------------------------------------------
代码如上,我放到页面代码里就不会出错
一放到类里供外部调用就会提示"请求在此上下文中不可用 "的错误
哪位出来指点一下,谢谢..

解决方案 »

  1.   

    想拥有一个非常稳定、速度又快、全自助双线主机吗?
    还在犹豫什么,互通数据是你最好的选择。

    详情请访问:http://www.515dns.com 
    QQ:287895593
      

  2.   

    Request是Page类的一个property
    你单独拎出来就访问不到该property了
      

  3.   

    把Page传进去:
    public string pd_price_show(Page page)
        {
            string result = null;
            //HttpCookie cookie=Request.Cookies["mycookie"]; 
            if (page.Request.Cookies["mycookie"] != null)
            {
                HttpCookie cookie = page.Request.Cookies["mycookie"];
                if (cookie.Values["userflag"].ToString() == "1")
                {
                    result = "1";
                }
                else
                {
                    if (cookie.Values["userflag"].ToString() == "3")
                    {
                        result = "3";
                    }
                }
            }
            else
            {
                result = "2";
            }
            return result;
        } 
    页面调用:
    new Class1().pd_price_show(this);
      

  4.   

    你需要右键添加引用:
    System.Web
    然后添加命名空间:
    System.Web.UI.Page
      

  5.   

    解决了
    继承ui.page过来就行了
    按cppfaq 说的方法就OK了
    谢谢
    结贴..