473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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
advance.

-Jim Fisher

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


Feb 15 '06 #1
0 1141

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Björn Marthen | last post by:
Hi, I have written a custom web control with a DesignSerializer. If i change a property in design-time, the serializer starts before the properties will be set in the control (the object "value"...
0
by: Frank VDL | last post by:
Hi, I've created my own component that uses the CodeDomSerializer to generate some extra code in the "InitizializeComponent" Every thing seems to work fine, until I compile my app... Every...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
1
by: Wannabe_Geek | last post by:
Hi Iam new to MS .Net technology just getting along with it....I created a custom control ,which takes in a query and displays the data in a tabular format....something similar to a datagrid. ...
2
by: Suzanne | last post by:
Hi all, I'm reposting this message as I'm experiencing this problem more and more frequently : I really hope someone out there can help me as I've been tearing my hair out on this one for a...
1
by: onyxring | last post by:
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...
0
by: onyxring | last post by:
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...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
1
by: EvilProject | last post by:
Hi, I'm writing a custom codedomserializer for a control(using DesignerSerializer). It works great but i can only insert statements to the initializecompenet method. I want to create a methods in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.