protected void Page_Load(object sender, EventArgs e) { Avatar.Attributes.Add("title", "mxit:table:update"); Parts.Attributes.Add("title", "mxit:table:update"); string postData = Request.Params[null]; //Gaming gaming = new Gaming(parts, "Post.aspx"); JavaScriptSerializer jss = new JavaScriptSerializer(); TableReply reply = jss.Deserialize<TableReply>(postData); //parts.Visible = true; //parts.Attributes.Add("title", "mxit:table:update"); if (reply.Selected.Count > 0) { CellCoord c = reply.Selected[0]; Table prevParts = (Table)Session["partstable"]; Table prevAvatar = (Table)Session["avatartable"]; String id = prevParts.Rows[c.Row].Cells[c.Col].Attributes["data-mxit-init"]; String prevav = prevAvatar.Rows[0].Cells[0].Attributes["data-mxit-init"]; id = id.Substring(id.IndexOf("['")+2); id = id.Substring(0,id.IndexOf("']")); id = "B" + id; String tempid = id.Substring(0, id.IndexOf(".")+1); TableCell cell = prevAvatar.Rows[0].Cells[0]; Gaming avatar = new Gaming(Avatar, "Post.aspx"); avatar.AddRow(); using (TableCell newTC = new TableCell()) { newTC.CopyBaseAttributes(cell); newTC.ID = cell.ID; newTC.Text = cell.Text; foreach (string key in cell.Attributes.Keys) { newTC.Attributes.Add(key, cell.Attributes[key]); } foreach (string k in cell.Style.Keys) { newTC.Style.Add(k, cell.Style[k]); } avatar.CurrentRow.Cells.Add(newTC); } if (prevav.Contains(",'" + id + "'")) { Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Replace(",'" + id + "'", ""); } else if (prevav.Contains(",'" + tempid )) { prevav = prevav.Remove(prevav.IndexOf(",'" + tempid),(",'" + tempid).Length+2); //remove old item and replace with new one Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Insert(prevav.IndexOf(']'), ",'" + id + "'"); } else { Avatar.Rows[0].Cells[0].Attributes["data-mxit-init"] = prevav.Insert(prevav.IndexOf(']'), ",'" + id + "'"); } Session["avatartable"] = Avatar; } }