帮忙看一下,为什么老报引用不存在应很简单
页面中private void Gobutton_Click代码可以正常使用,但我单独放到一个.cs文件中老报引用不存在
页面后台代码
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
namespace Webab
{
/// <summary>
/// WebForm 的摘要说明。
/// </summary>
public class WebForm : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label ListStr;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Gobutton;
.
.
.
private void Gobutton_Click(object sender, System.EventArgs e)
{
if (! (Request.Cookies["Cookie1"] == null))
{
System.Collections.Specialized.NameValueCollection UserInfoCookieCollection = null;
UserInfoCookieCollection = Request.Cookies["Cookie1"].Values;
ListStr.Text = Server.HtmlEncode(UserInfoCookieCollection["Val1"]);
}
}
独立.cs类文件中
namespace Webab
{
/// <summary>
/// LoginClass 的摘要说明。
/// </summary>
public class LoginClass
{
public LoginClass()
{
//
// TODO: 在此处添加构造函数逻辑
//
public static string Login()
{
string loginbadge,tempname;
//此处代码是一样的
if (! (Request.Cookies["Cookie1"] == null))
{
System.Collections.Specialized.NameValueCollection UserInfoCookieCollection = null;
UserInfoCookieCollection = Request.Cookies["Cookie1"].Values;
ListStr.Text = Server.HtmlEncode(UserInfoCookieCollection["Val1"]);
return loginbadge;
}
}