Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6051489
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:49:31+00:00 2026-05-23T07:49:31+00:00

I get this when I put a dictionary into a ViewState. Type ‘System.Web.UI.WebControls.Table’ in

  • 0

I get this when I put a dictionary into a ViewState.

Type 'System.Web.UI.WebControls.Table' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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 'System.Web.UI.WebControls.Table' in Assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' 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.

What I dont understand, is how do I get rid of that exception…I know that i need to make something serializable..but what?

The dictionary looks like that:

Dictionary<string, List<DisplayAllQuestionsTable>> tPages;

DisplayAllQuestionsTable has got a table webcontrol in it that is generated programmatically

Class to serialize:

[Serializable()]
    public class DisplayAllQuestionsTable 
    {
        Table Tmain = new Table();
        TableRow threadRow;
        Label viewsLabel;
        Label repliesLabel;
        TableCell qTitle;
        TableCell qView;
        TableCell qReplies;
        TableCell qAvatar;
        TableCell moderatorDelete;
        HyperLink q;
        Label lastPostedBy;
        TableCell tCellLastPostedBy;
        Button btnMoveThread;
        Button btnDeleteThread;
        TableCell tCellmoderaterControls;
        Dictionary<string, string[]> allTopics;
        DropDownList drpDnTopics;
        DropDownList drpDnsubtopics;
        AllQuestions page;
        string Name { get; set; }
        string ThreadName { get; set; }
        string Topic { get; set; }
        string Subtopic { get; set; }
        int Views { get; set; }
        int Replies { get; set; }
        int PageNumber { get; set; }
        DateTime Time { get; set; }
        PlaceHolder holder2;
        public DisplayAllQuestionsTable(AllQuestions formPage, string name, string ThreadTitle, string topic, string subtopics, int views, int replies, int pageNumber, DateTime time, PlaceHolder pholder)
        {
            page = formPage;
            Name = name;
            ThreadName = ThreadTitle;
            Topic = topic;
            Subtopic = subtopics;
            Views = views;
            Replies = replies;
            PageNumber = pageNumber;
            DateTime Time = time;
            holder2 = pholder;
        }



        public void ExecuteAll()
        {
            CreateTable();

            feedInformation();
            CreateLabels();
            InitializeCells();
            AddControlsToCells();
            if (HttpContext.Current.User.IsInRole("Administrators") || HttpContext.Current.User.IsInRole("Moderators"))
            {

                AddModeratorControls();
                ManageDropDownList();
                initializeManagerControls();
                AddModeraterCells();
                ModeraterAddCellsToRows();
            }


            AddCellsToRows();

            if (HttpContext.Current.User.IsInRole("Administrators") || HttpContext.Current.User.IsInRole("Moderators"))
            {

                ModeraterAddCellsToRowsDelete();
            }
            CreateTable();
            holder2.Controls.Add(Tmain);
            // page.Form.Controls.Add(Tmain);
        }


        void feedInformation()
        {
            /*
             * Functions:
             * 1) SQLCommand= find all the question
             * 2) SQLCommnad= find the view per question
             * 3) SQLCommand= find the replies per thread
             * 4) SQLCommand= extract all Users avatars.
             * 5) Add functions to check the amount of questions. 
             * if too many questions swap pages (add a page button).
             * 6) The Moderator will have the authority to delete question
             * and move it to a different place. - New move buttons should be added!
             * 
             */
            q = new HyperLink();
            q.Text = ThreadName;
            q.NavigateUrl = "AnswerQuestion.aspx";
            allTopics = new Dictionary<string, string[]>();
            allTopics = AllQuestions.AllTopics();
        }

        void AddModeratorControls()
        {
            btnMoveThread = new Button();
            btnMoveThread.Text = "העבר ל";
            btnDeleteThread = new Button();
            btnDeleteThread.Text = "מחק";

            drpDnTopics = new DropDownList();
            drpDnsubtopics = new DropDownList();
            drpDnsubtopics.Width = 120;
            drpDnTopics.AutoPostBack = true;
            drpDnTopics.SelectedIndexChanged += topicDropDownMenu_SelectedIndexChanged;
        }

        void ManageDropDownList()
        {

            foreach (var item in allTopics)
            {
                drpDnTopics.Items.Add(item.Key);
            }
        }

        void topicDropDownMenu_SelectedIndexChanged(object sender, EventArgs e)
        {
            drpDnsubtopics.Items.Clear();
            string[] chosenItem = allTopics[drpDnTopics.SelectedItem.Value];

            foreach (string item in chosenItem)
            {
                drpDnsubtopics.Items.Add(item);
            }
        }

        void CreateLabels()
        {
            //Call everytime a question is inserted.
            viewsLabel = new Label();
            repliesLabel = new Label();
            lastPostedBy = new Label();

            viewsLabel.Text = "צפיות" + "<br/>" + Views;
            repliesLabel.Text = "תגובות" + "<br/>" + Replies;
            lastPostedBy.Text = "בעל אשכול" + "<br/>" + Name;
        }

        void initializeManagerControls()
        {
            tCellmoderaterControls = new TableCell();
            moderatorDelete = new TableCell();

            tCellmoderaterControls.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
        }

        void InitializeCells()
        {
            //Initialize all controls
            threadRow = new TableRow();
            qTitle = new TableCell();
            qView = new TableCell();
            qReplies = new TableCell();
            qAvatar = new TableCell();
            tCellLastPostedBy = new TableCell();


            //Adding all controls
            qTitle.Width = 470;
            qTitle.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Right;
            tCellLastPostedBy.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
            qView.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;
            qReplies.HorizontalAlign = System.Web.UI.WebControls.HorizontalAlign.Center;

            qTitle.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
            tCellLastPostedBy.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
            qView.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
            qReplies.VerticalAlign = System.Web.UI.WebControls.VerticalAlign.Middle;
            qTitle.Controls.Add(q);
        }

        void AddControlsToCells()
        {
            //Call everytime a question in inserted.

            qReplies.Controls.Add(repliesLabel);
            qView.Controls.Add(viewsLabel);
            tCellLastPostedBy.Controls.Add(lastPostedBy);
        }

        void AddModeraterCells()
        {

            tCellmoderaterControls.Controls.Add(btnDeleteThread);
            tCellmoderaterControls.Controls.Add(drpDnsubtopics);
            tCellmoderaterControls.Controls.Add(drpDnTopics);
            tCellmoderaterControls.Controls.Add(btnMoveThread);
            moderatorDelete.Controls.Add(btnDeleteThread);
        }

        void ModeraterAddCellsToRows()
        {
            threadRow.Cells.Add(tCellmoderaterControls);

        }

        void AddCellsToRows()
        {
            //Call everytime a question is inserted

            threadRow.Cells.Add(qView);
            threadRow.Cells.Add(qReplies);
            threadRow.Cells.Add(tCellLastPostedBy);
            threadRow.Cells.Add(qAvatar);
            threadRow.Cells.Add(qTitle);
            Tmain.Rows.Add(threadRow);
        }

        void ModeraterAddCellsToRowsDelete()
        {


            threadRow.Cells.Add(moderatorDelete);
        }

        void CreateTable()
        {
            //Call only once
            Tmain.Width = 1000;
            Tmain.BorderColor = System.Drawing.Color.Black;
            Tmain.BorderWidth = 1;
            Tmain.CellPadding = 3;
    }

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:49:31+00:00Added an answer on May 23, 2026 at 7:49 am

    Looks like you’re trying to serialize a table control rather than a dictionary. Are you databinding the dictionary to the table control? If so, try serializing the dictionary rather than the table control and then rebinding on page load.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHP detecting request type (GET, POST, PUT or DELETE) This should be
i get this error {Method 'System.DateTime ConvertTimeFromUtc(System.DateTime, System.TimeZoneInfo)' has no supported translation to SQL.}
I get this error: Can't locate Foo.pm in @INC Is there an easier way
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
I get this error:- You have an error in your SQL syntax; check the
We get this error in Visual Studio 2005 and TFS very often. Can anyone
I get this message: Cannot find the X.509 certificate using the following search criteria:
I get this error message when installing SQL 2005 Analysis services. The cabinet File
I get this message when trying to communicate with software that communicates with SOAP?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.