471,317 Members | 1,792 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

CodeDomSerializer and Asp.Net custom control

I've been building custom web controls in C# with VS2005. Currently I'm
looking into adding design-time functionality and have reached a point where
I need to generate code in the page the custom control is on. Enter the
CodeDomSerializer class.

I've found several examples creating Designer Serializers, nearly all of
them for windows forms, but a few claiming to work for Web Controls;
however, I have been singularly unsuccessful at every attempt to modify
source code during the design-time experience. Clearly I'm doing something
wrong, but what it is escapes me.

Below is a sample of the technique I've been using, scaled down to the
barest minimum and excluding designers and other things you might expect for
a custom control. It appears to me that this should work, though adding this
"newtest" control to a page clearly does not add the comment expected.

Can anyone add some clarity at to what I'm doing wrong? Thank you in

-Jim Fisher

/--/begin sample code....
namespace testcontrol {
public partial class newtest : System.Web.UI.WebControls.TextBox {
public newtest() {
public newtest(IContainer container) {
internal class newtest_serializer : CodeDomSerializer {
public override object Deserialize(IDesignerSerializationManager
manager, object codeObject) {
CodeDomSerializer serial =
(CodeDomSerializer)manager.GetSerializer(typeof(ne wtest).BaseType,
return serial.Deserialize(manager,codeObject);
public override object Serialize(IDesignerSerializationManager
manager, object value) {
CodeDomSerializer serial =
(CodeDomSerializer)manager.GetSerializer(typeof(ne wtest).BaseType,
CodeStatementCollection statements =
(CodeStatementCollection)serial.Serialize(manager, value);
statements.Add(new CodeCommentStatement("//--Comment!--"));
return statements;

Feb 15 '06 #1
0 1059

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Björn Marthen | last post: by
reply views Thread by Frank VDL | last post: by
21 posts views Thread by One Handed Man \( OHM - Terry Burns \) | last post: by
1 post views Thread by Wannabe_Geek | last post: by
1 post views Thread by onyxring | last post: by
reply views Thread by onyxring | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.