~刚才关于类的写法问题已经解决,,谢谢大家了。
只是后面又提了个问题似乎没人看到,没办法,,只好另外开贴了。。
第一页代码:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}
public RegistrationInformation RegistrationInformation
{
get
{
RegistrationInformation host=new RegistrationInformation();
host.Name = TextBox1.Text;
if (RadioButton1.Checked == true)
host.Sex = "男";
else
host.Sex = "女";
host.Nation = DropDownList1.SelectedValue;
return host;
}
}
}
第二页代码:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RegistrationInformation host = PreviousPage.RegistrationInformation;
Label1.Text = host.Name;
Label2.Text = host.Sex;
Label3.Text = host.Nation;
}
}
//======================================================
错误
“System.Web.UI.Page”并不包含“RegistrationInformation”的定义 //=========================================================问题应该出在第一页的那个按纽。。因为那里没有调入类,所以导致第二页找不到这个类吧。。
类在第一页作为PUBLIC~如何调用进去呢?
只是后面又提了个问题似乎没人看到,没办法,,只好另外开贴了。。
第一页代码:
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("Default2.aspx");
}
public RegistrationInformation RegistrationInformation
{
get
{
RegistrationInformation host=new RegistrationInformation();
host.Name = TextBox1.Text;
if (RadioButton1.Checked == true)
host.Sex = "男";
else
host.Sex = "女";
host.Nation = DropDownList1.SelectedValue;
return host;
}
}
}
第二页代码:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
RegistrationInformation host = PreviousPage.RegistrationInformation;
Label1.Text = host.Name;
Label2.Text = host.Sex;
Label3.Text = host.Nation;
}
}
//======================================================
错误
“System.Web.UI.Page”并不包含“RegistrationInformation”的定义 //=========================================================问题应该出在第一页的那个按纽。。因为那里没有调入类,所以导致第二页找不到这个类吧。。
类在第一页作为PUBLIC~如何调用进去呢?
跟第一页没关系,网页中传数据不是这么传的哦
通过对象来访问
怎么感觉你在做winform程序
跟第一页没关系,网页中传数据不是这么传的哦//=============================================呵呵,我是尝试调用类的方法把值赋过去,,熟悉类的使用
----------------------------------------------------
gui0605(千分散尽还复来)
_Default objDefault1 = new _Default();
通过对象来访问
//===========================================================
第二个窗口的Page_Load里面吗?
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{ }
protected void Button1_Click(object sender, EventArgs e)
{
Server.Transfer("Default2.aspx");
}
public string name
{
get
{
return TextBox1.Text;
}
}
public string sex
{
get
{
return RadioButton1.Checked ? "男" : "女";
}
}
public string nation
{
get
{
return DropDownList1.SelectedValue;
}
}
}
第二页代码:
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
_Default default = (_Default)Context.Handler ;
Label1.Text = default.name;
Label2.Text = default.sex;
Label3.Text = default.nation;
}
}
public string sex
{
get
{
return RadioButton1.Checked ? "男" : "女";
}
}:)~
把类放session里传
//===========================================
那还不如直接就用Seesion传嘛。。就是想了解下类的传值方法。。