473,397 Members | 2,084 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,397 software developers and data experts.

CodeDomSerializer and Design time code generation

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
Feb 12 '06 #1
1 2139
> 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.


Um... here's the sample (sorry):
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("//--------
CodingComment--------"));
return statements;
}
}
}

Feb 13 '06 #2

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

Similar topics

9
by: bigoxygen | last post by:
Hi. I'm using a 3 tier FrontController Design for my web application right now. The problem is that I'm finding to have to duplicate a lot of code for similar functions; for example, listing...
4
by: clintonG | last post by:
I'd like to know about application(s) or the name by which the following process is referred which would allow a business analyst to enter the following statements which when submitted would result...
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...
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...
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...
7
by: JJ | last post by:
Having done most of the background sql coding I'm now ready to start designing my asp.net web pages. A basic question though - is there a way of having 'common' elements on pages (e.g. a...
13
by: news.microsoft.com | last post by:
I'm trying to develop a ASP.NET app with OO + 3-tier design, here is a scenario: if there is a People class which is defined as below, class People { string ID; string FirstName; string...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.