473,800 Members | 2,738 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CodeDomSerializ er 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
CodeDomSerializ er 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 2158
> 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 {
[DesignerSeriali zer(typeof(newt est_serializer) ,
typeof(CodeDomS erializer))]
public partial class newtest : System.Web.UI.W ebControls.Text Box {
public newtest() {
InitializeCompo nent();
}
public newtest(IContai ner container) {
container.Add(t his);
InitializeCompo nent();
}
}
internal class newtest_seriali zer : CodeDomSerializ er {
public override object Deserialize(IDe signerSerializa tionManager
manager, object codeObject) {
CodeDomSerializ er serial =
(CodeDomSeriali zer)manager.Get Serializer(type of(newtest).Bas eType,
typeof(CodeDomS erializer));
return serial.Deserial ize(manager,cod eObject);
}
public override object Serialize(IDesi gnerSerializati onManager
manager, object value) {
CodeDomSerializ er serial =
(CodeDomSeriali zer)manager.Get Serializer(type of(newtest).Bas eType,
typeof(CodeDomS erializer));
CodeStatementCo llection statements =
(CodeStatementC ollection)seria l.Serialize(man ager, value);
statements.Add( new CodeCommentStat ement("//--------
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
3868
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 users, and listing assignments use similar type commands. Is there a "better" way I can organize my code?
4
2386
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 in the generation of class library members... "Are you an individual person not working?" if no, ask "have you ever worked for an employer?" if no, ask "Are you thirteen years of age or younger?" ...
1
3124
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" in the serialize method has the old property value). Thats annoying cause the serialize should write somthing to the code that depends on the property. Does anyone know a solution for my problem?
0
1022
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 time I compile my application, all generated code is lost ? What is going wrong ?
0
1080
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 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...
0
1183
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 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...
7
1290
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 header)? This used to be done using frames, but I undertand these are now not advised. Basically what I want is to have some text/code that is common to all pages, but that I only need to update in one place?
13
1350
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 LastName; string Address; string Tel;
1
2204
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 the container of the control outside the initalizecomponent method. how can this be done?
0
9690
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9550
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10501
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10250
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10032
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5603
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2944
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.