473,788 Members | 2,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CodeDomSerializ er 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
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

/--/begin sample code....
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("//--Comment!--"));
return statements;
}
}
}


Feb 15 '06 #1
0 1177

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

Similar topics

1
3123
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 ?
21
2105
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 string with comma delimited values. For example, if I were to render two text boxes. One with the Value Terry and the Other with the Value 'Burns' I would get the following value Terry,Burns.
1
1869
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. Since its a custom Control I drag and drop and use it in my Pages. I overload the render method of my Custom Control and I pass the data that is to be displayed. Now there is a requisite I have to add a Control ( Say for ex a Dropdown List box)...
2
2597
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 good while and I'm getting really frustrated now! My problem is this - my custom controls periodically disappear from my
1
2157
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
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...
15
6523
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 accept other controls. The control i drag drop on it becomes the child of my custom control's parent form and not the child of my custom control. Then i added this line "" before my custom control class (i dont know what this line does). Now
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
9656
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
9498
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
10366
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...
0
10173
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9967
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...
1
7517
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5536
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4070
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
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.