Click here to Skip to main content
14,448,369 members
Rate this:
Please Sign up or sign in to vote.
hi why this cod have error when generat the xml document?
plz help me
tanx


private void CreateForm()
   {

       DForm form1 = new DForm() { Name = "Form1" };
       DPage page1 = new DPage() { PageNumber = 1 };
       DPage page2 = new DPage() { PageNumber = 2 };
       DSection p1s1 = new DSection() { SectionType = 2 };
       DSection p1s2 = new DSection() { SectionType = 2 };
       //DSection p1s3 = new DSection() { SectionType = 2 };
       //DSection p1s4= new DSection() { SectionType = 2};
       DSection p2s1 = new DSection() { SectionType = 1 };
       DSection p2s2 = new DSection() { SectionType = 1 };


       DControl p1s1c1 = new DNameControl { Title = "textbox", id = Guid.NewGuid().ToString() };
       DControl p1s1c2 = new DNameControl { Title = "checkbox", id = Guid.NewGuid().ToString() };
       //DControl p1s1c3 = new DNameControl { Title = "BUtton", id = Guid.NewGuid().ToString() };
       //DControl p1s1c4 = new DNameControl { Title = "FileUpload", id = Guid.NewGuid().ToString() };
       DControl p1s2c1 = new DNameControl { Title = "label", id = Guid.NewGuid().ToString() };
       DControl p1s2c2 = new DNameControl { Title = "dropdown", id = Guid.NewGuid().ToString() };
       //DControl p1s2c3 = new DNameControl { Title = "radioButton", id = Guid.NewGuid().ToString() };
       //DControl p1s2c4 = new DNameControl { Title = "CheckBoxList", id = Guid.NewGuid().ToString() };




       DControl p2s1c1 = new DNameControl { Title = "Image", id = Guid.NewGuid().ToString() };
       DControl p2s1c2 = new DNameControl { Title = "ListBox", id = Guid.NewGuid().ToString() };
       DControl p2s2c1 = new DNameControl { Title = "label", id = Guid.NewGuid().ToString() };
       DControl p2s2c2 = new DNameControl { Title = "RadioButtonList", id = Guid.NewGuid().ToString() };



       p1s1.Controls.Add(p1s1c1);
       p1s1.Controls.Add(p1s1c2);


       p1s2.Controls.Add(p1s2c1);
       p1s2.Controls.Add(p1s2c2);

       p2s1.Controls.Add(p2s1c1);
       p2s1.Controls.Add(p2s1c2);

       p2s2.Controls.Add(p2s2c1);
       p2s2.Controls.Add(p2s2c2);

       page1.Sections.Add(p1s1);
       page1.Sections.Add(p1s2);

       page2.Sections.Add(p2s1);
       page2.Sections.Add(p2s2);


       form1.Pages.Add(page1);
       form1.Pages.Add(page2);

       try
       {


           XmlSerializer serializer = new XmlSerializer(typeof(DForm));
           StringBuilder sb = new StringBuilder();

           StringWriter writer = new StringWriter(sb);

           using (writer)
           {
               serializer.Serialize(writer, form1);
               String formDef = Convert.ToString(sb);
               Session["FormDef"] = formDef;
               Response.Redirect("~/default4.aspx");
               //LiteralControl lc = new LiteralControl(Server.HtmlEncode(formDef));
              // p1.Controls.Add(lc);
           }

       }
       catch (Exception ex)
       {
           LiteralControl lc = new LiteralControl(ex.ToString());
           p1.Controls.Add(lc);
       }



   }
Posted
Comments
Mehdi Gholam 1-Sep-15 5:00am
   
The XML serializer is not meant to work with WinForms.
digimanus 1-Sep-15 9:51am
   
on which line?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100