hallo iam getting this error message when the page is load,
Type ‘messageBox’ in Assembly ‘App_Code.e9hyffkh, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’ is not marked as serializable.
iam new in asp.net , and i can find what iam going worng!
heres my code:
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 = "";
}
Add
[Serializable]attribute on top of yourmessageBoxclass.For reference: SerializableAttribute Class