你好,我在加载页面时收到此错误消息,
在程序集“App_Code.e9hyffkh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null”中键入“messageBox”未标记为可序列化。
我是 asp.net 的新手,我可以找到我要穿的东西!
这是我的代码:
public partial class home : System.Web.UI.Page
{
public string val = "";
public string data = "";
protected void Page_Load(object sender, EventArgs e)
{
val = "";
if (!IsPostBack)
{
ViewState["Messages"] = new List<messageBox>();
}
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
var messages = (List<messageBox>)ViewState["Messages"];
if (text1.Text == "")
{
val = "נא הכנס שם";
}
else
{
messages.Add(text1.Text);
val = "נוסף בהצלחה";
}
ListBox1.DataSource = messages;
ListBox1.DataBind();
ViewState["Messages"] = messages;
data = messages.Count.ToString();
text1.Text = "";
}