Serializer for dynamic control

using System;
using System.IO;
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
using System.Web;
using System.Text;

public class Serializer
{
    
"Serialize"

    
"Deserialize"

    
"WebSerialize"

    
"WebDeserialize"
}

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.IO;
using System.Text;

public partial class _Default : System.Web.UI.Page 
{
    #region "OnInit"
    protected override void OnInit(EventArgs e)
    {
        //base.OnInit(e);
        //string inform = Request.Form[hfHolder.ClientID];
        //if (!string.IsNullOrEmpty(inform))
        //{
        //    string[] array = inform.Split(';');
        //    string type = array[0];
        //    string id = array[1];
        //    if (type == "TextBox")
        //    {
        //        TextBox tb = new TextBox();
        //        tb.ID = id;
        //        PlaceHolder1.Controls.Add(tb);
        //    }
        //}
    }
    #endregion

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(hfHolder.Value))
        {
            Hashtable h = Serializer.WebDeserialize(hfHolder.Value) as Hashtable;
            Response.Write(h["test"].ToString());
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        //if (string.IsNullOrEmpty(hfHolder.Value))
        //{
        //    TextBox tb = new TextBox();
        //    tb.ID = "test";
        //    PlaceHolder1.Controls.Add(tb);
        //    hfHolder.Value = "TextBox;test";
        //}
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Hashtable h = new Hashtable();
        h.Add("test", "007");
        hfHolder.Value = Serializer.WebSerialize(h);
    }
}
posted @ 2008-06-19 23:59  N/A2011  阅读(199)  评论(0编辑  收藏  举报