![]() |
|
|
|||||||
![]() |
ASP Net - Design Time support for custom ASP.Net controls |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
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; } } } onyxring |
|
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Dawn Of Internet Video, REVENGE of Time Warner Cable! | Derek Currie | DVD Video | 4 | 01-21-2008 09:28 PM |
| HELP needed in solving a run time error in ASP.NET | hudhu_handhu | Software | 0 | 09-13-2006 09:34 AM |
| This is incredible! | jc_ice | DVD Video | 1 | 08-13-2006 10:47 AM |
| As growth slows, Hollywood faces a DVD standoff. | Allan | DVD Video | 0 | 07-11-2005 02:10 PM |
| New DVD standard gains support. | Allan | DVD Video | 0 | 01-18-2004 08:20 PM |