public partial class Index : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (ViewState["NameOfUser"] != null)
{
Model.Md_QUESTION md = (Model.Md_QUESTION)ViewState["NameOfUser"];
NameLabel.Text = "" + md.Question_id ;
}
else
NameLabel.Text = "Not set yet...";
}
protected void SubmitForm_Click(object sender, EventArgs e)
{
Model.Md_QUESTION md = new Model.Md_QUESTION();
md.Question_id = System.Convert.ToInt32(NameField.Text);
ViewState["NameOfUser"] = md;
NameLabel.Text = ""+md.Question_id;
}
}
อันนี้เป็ร Error ครับ Code
Type 'Model.Md_QUESTION' in Assembly 'App_Code.pn1ae64b, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Runtime.Serialization.SerializationException: Type 'Model.Md_QUESTION' in Assembly 'App_Code.pn1ae64b, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' is not marked as serializable.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
namespace Model
{
public class Md_QUESTION
{
private int question_id = 0;
private string question_name = null;
public int Question_id
{
get { return question_id; }
set { question_id = value; }
}
public string Questiob_name
{
get { return question_name; }
set { question_name = value; }
}
}
}
namespace Model
{
[Serializable]
public class Md_QUESTION
{
private int question_id = 0;
private string question_name = null;
public int Question_id
{
get { return question_id; }
set { question_id = value; }
}
public string Questiob_name
{
get { return question_name; }
set { question_name = value; }
}
}
}