473,386 Members | 1,830 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,386 software developers and data experts.

Design Time support for custom ASP.Net controls

I'm reposting this, because I had a bit of difficulty last time and think
that it might have fallen through the cracks. If I'm posting to the wrong
groups, please let me know. Surely someone has some experience with this...

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 1380

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

Similar topics

2
by: SammyBar | last post by:
Hi, I'm trying to bind a custom collection class to a data grid, following the guidelines from the article http://msdn.microsoft.com/msdnmag/issues/05/08/CollectionsandDataBinding/default.aspx....
17
by: tshad | last post by:
Many (if not most) have said that code-behind is best if working in teams - which does seem logical. How do you deal with the flow of the work? I have someone who is good at designing, but...
7
by: Shimon Sim | last post by:
I have a custom composite control I have following property
3
by: George Jordanov Ivanov | last post by:
Folks, I am implementing a WebUserControl, which will have its own custom event StateChanged. Now, I want to add this event to the Events tab in the control properties, so that the users of my...
0
by: Brant Estes | last post by:
So try this. Create a new ASP.NET 2.0 website. Add a theme. Add a skin to the theme. In your web.config, add the <pages theme="MyTheme" styleSheetTheme="MyTheme" /tag under your system.web...
4
by: Mark Olbert | last post by:
I've written a composite custom control which I would like to have update its design-time display when one of several properties changes at design time. These custom properties are not simply the...
1
by: Mark Olbert | last post by:
Has anyone else noticed that the design-time support for databinding in custom controls in ASPNET2 sucks? At least for GridViews? So far I've spent going on two days trying to get the following...
1
by: | last post by:
How do you debug the design time behavior of user controls? I have code in the controls resize event and I've flagged a break point, but the code never breaks when I play with the control on the...
4
by: Ken Fine | last post by:
I've been living with a frustrating issue with VS.NET for some months now and I need to figure out what the problem is. Hopefully someone has run into the same issue and can suggest a fix. I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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...
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...
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
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,...

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.