CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > windows_hosting.hosting_open_forum Tags:
Item Type: NewsGroup Date Entered: 9/25/2003 9:12:15 PM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 1 Views: 17 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
2 Items, 1 Pages 1 |< << Go >> >|
threecrans
Asp.Net User
Problems serializing WebControl to XML using XmlSerializer9/25/2003 9:12:15 PM

0/0

Reposted from XML forum. This probably has more to do with control building then XML.

I have a feeling I'm missing something simple here. I cannot get even the most simple WebControl to be serialized into an XML file. I keep getting an error "System.Web.UI.WebControls.WebControl cannot be serialized because it does not have a default public constructor. ", although it appears my WebControl does indeed have a default public constructor. Here is my control code.

using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using System.Xml.Serialization;
using System.IO;

namespace SerializeTest
{
[
ToolboxData("<{0}:MyControl runat=server></{0}:MyControl>"),
Serializable
]
public class MyControl : System.Web.UI.WebControls.WebControl
{
public MyControl():base()
{
}

private string text;

public string Text
{
get
{
return text;
}

set
{
text = value;
}
}

protected override void Render(HtmlTextWriter output)
{
output.Write(Text);
}

public void SaveConfiguration(string filepath)
{
XmlSerializer serializer = new XmlSerializer(typeof(MyControl));
TextWriter writer = new StreamWriter(filepath);
serializer.Serialize(writer, this);
writer.Close();
}
}
}

And here is the code of my test application

MyControl1.Text = "blah";
MyControl1.SaveConfiguration("C:\\Temp\\MyConfig.xml");

Thanks for any info/feeback.
joteke
Asp.Net User
Re: Problems serializing WebControl to XML using XmlSerializer9/26/2003 7:47:21 AM

0/0

Hi,

it doesn't claim that your control wouldn't have public default constructor but WebControl itself (base class of your control) doesn't have, it is protected. In other wrods, your Control can't be serialized because it's base class isn't serializable.

I think what you are trying to do could be solved pretty near by using typeconverters which are used to convert objects to strings and again returns objects instances from those strings. Though they don't necessarily returns XML by default, though they can easily be to do that as thwe string format TypeConverter uses, is completely up to the developer.

Here is about developing a typeconverter:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconimplementingtypeconverter.asp
Thanks,

Teemu Keiski
Finland, EU
2 Items, 1 Pages 1 |< << Go >> >|


Free Download:


Web:
Problems serializing WebControl to XML using XmlSerializer - ASP ... Problems serializing WebControl to XML using XmlSerializer. Last post 09-26-2003 3:47 AM by joteke. 1 replies. Sort Posts: ...
ASP.NET Server Control: Cannot serialize the object using ... WebControls; using System.ComponentModel; using System.Xml.Serialization; ... 2, Generating XML with XmlSerializer without namespaces at all nodes · C# ...
Simple Serialization Jun 7, 2006 ... WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI. HtmlControls; using System.Xml.Serialization; using System. ...
microsoft.public.dotnet.framework.webservices: Serialization ... System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader ... Serialization problem, using .NET client to access Java (Apache Axis) Web Service ...
InvalidCastException upon serializing IXmlSerializable class at System.Xml.Serialization.XmlSerializer.Serialize(XmlWriter ... guess this means that I have problems with my schemas somewhere, but ...
MSDN SharePoint - Development and Programming Facing problem while ... Facing problem while adding web part in Sharepoint2007 using ... Xml. Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, ...
Mailing list archives Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader) +24 System.Web. ... WebControls.Button.OnClick(EventArgs e) +108 System.Web.UI.WebControls. ...
— Patrick Altman Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web . .... Xml.Serialization.XmlSerializer) with lines of code similar to this: ...
How to serialize a Barcode Professional object using System.Xml.Serialization; using Neodynamic.WinControls.BarcodeProfessional ; ... 'XML Serialization - Save Menu Option Dim xmls As XmlSerializer = New ...
.NET XML Page 7 - Bytes Site Map How to tell the XmlSerializer to ignore all namespaces · Good way to read this XML .... Can xml request go through firewall by using web service? ...




Search This Site:










host options doesnt show

how to get the source code?

bringing it back to web development style

green, yellow, red & color blind

compositedataboundcontrol: some questiosn about formview

css style items please can you tell me what these do?

login/loout status ?

how to link a page in ddn from an html-code not with the tab-id, but with the tab's name ?

web deployment projects

restricted access to dnn admin features

3.1.0 - okay...where can i find the new dnn 3.1.0 skin?

regarding ie webcontrols dll

permission denied on .dll

i'm sure this is simple, but how do you install a skin?

after i login, my page always get twice on every click, any idea? thanks

asp.net masterpages and menus integrating with prebuilt templates??

bug: annoying effect of tabs recoding for links

publish a web site using command line

deny access with principalpermissionattribute

app error

creating web project in visual studio 2005

treenode.text with an image causes a problem ?

cannot find automated message files for customization

debugging only a project og a solution

windows 2003 server and iis 6

switching between code/designer? (f7) (web application project type)

beta testers for text layout module required

handling server-side treeview events?

validating local users, passwords, and groups

testing on a live server is not a good idea

 
All Times Are GMT