Your use of [PersistenceMode(PersistenceMode.InnerProperty)] was causing the properties to serialize the way they were. By removing the attribute, you've changed back to the default, which is [PersistenceMode(PersistenceMode.Attribute)]. This makes a property
appear as an attribute in the control's tag. Hope that helps explain it a little!
However, in the designer, when i drag the control to the page. I only end up with
<jon:tabpage .....>
</jon:tabpage>
Which is incorrect, and leads to a design time error. I can go to source, fill in the missing detail, and then the designer works. But how can i get the designer to output the missing property/element when dragging into design view? Like it does in source
view?
Basically, i want the designer to recognize somehow, that it is placing a new 'tabpage' in, and it should give me a blank <tabbody> tag which is an Itemplate.
I am also wondering how to initizlize a blank Itemplate to display in the designer like a blank placeholder control, so if you know that, that would be great too !!!
Thanks in advance,
Jonathan
Jonathan Minond
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
The attribute you've got on your control should dictate how it appears when you drop the control into the page: [ToolboxData("<{0}:TabControl runat=\"server\" Width=\"125px\" Height=\"50px\">")] If you were to add the child tags to this attribute, you should
get the correct markup: [ToolboxData("<{0}:TabControl runat=\"server\" Width=\"125px\" Height=\"50px\"><{0}:tabpage>")] Alternatively, you could define this similarly at the level of your "tabpage" control, assuming "tabpage" is another user control. I'm not
sure why you're seeing the difference when dragging to the designer as opposed to code, though... I'd suggest you try the above and see what happens :)
jminond
Contributor
2898 Points
608 Posts
Designer Serialization Issue
May 29, 2006 09:36 PM|LINK
I have a compositecontrol. The question is at the end of the code post....
[preview of control at runtime, designer also works well....but my output is not exactly what i want]
[
ParseChildren(true, "TabPages")][ToolboxData("<{0}:TabControl runat=\"server\" Width=\"125px\" Height=\"50px\"></{0}:TabControl>")]
[PersistChildren(false)]
[Designer(typeof(TabControlDesigner))]
public class TabControl : CompositeControl
with properties
[
Category("Data")][Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Bindable(true)]
public string CaptionText [Category("Data")]
[Browsable(true)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Bindable(true)]
public string FooterText
currently when i edit those properties in the property browser they are serializing like
<CaptionText>sdfsdf
</CaptionText> <FooterText>sdfsdf
</FooterText>but what i want is for them to edit the control tag as attributes,
CaptionText="" and FooterText=""
Does anyone know how i can do this?
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
jminond
Contributor
2898 Points
608 Posts
Re: Designer Serialization Issue
May 29, 2006 10:29 PM|LINK
figured it out,
[
ParseChildren(true, "TabPages")][
ToolboxData("<{0}:TabControl runat=\"server\" Width=\"125px\" Height=\"50px\"></{0}:TabControl>")][
PersistChildren(false)][
Designer(typeof(TabControlDesigner))]public
class TabControl : CompositeControlpublic
string CaptionTextresult:
<
JFWC:TabControl ID="TabControl1" runat="server" CaptionText="dfgd" FooterText="dfgdg" Orientation="Vertical" >http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
DPuzey
Member
110 Points
22 Posts
Re: Designer Serialization Issue
May 30, 2006 02:09 PM|LINK
jminond
Contributor
2898 Points
608 Posts
Re: Designer Serialization Issue
May 30, 2006 02:24 PM|LINK
You where absolutly correct ;-)
I have another question....
Basically i have a "defautl" proeprty which is a template.
When i drag the control from toobox onto page in source view ( it renders as follows ).
<jon:tabpage .....>
<tabbody>
</tabbody>
</jon:tabpage>
That is correct.
However, in the designer, when i drag the control to the page. I only end up with
<jon:tabpage .....>
</jon:tabpage>
Which is incorrect, and leads to a design time error. I can go to source, fill in the missing detail, and then the designer works. But how can i get the designer to output the missing property/element when dragging into design view? Like it does in source view?
Basically, i want the designer to recognize somehow, that it is placing a new 'tabpage' in, and it should give me a blank <tabbody> tag which is an Itemplate.
I am also wondering how to initizlize a blank Itemplate to display in the designer like a blank placeholder control, so if you know that, that would be great too !!!
Thanks in advance,
Jonathan
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx
DPuzey
Member
110 Points
22 Posts
Re: Designer Serialization Issue
May 31, 2006 10:56 AM|LINK
DPuzey
Member
110 Points
22 Posts
Re: Designer Serialization Issue
May 31, 2006 11:13 AM|LINK
[ToolboxData("<{0}:TabControl runat=\"server\" Width=\"125px\" Height=\"50px\"><{0}:tabpage><tabbody></tabbody></{0}:tabpage></{0}:TabControl>")]
Bloody XML tags that don't render properly when you post from Opera [:|]
jminond
Contributor
2898 Points
608 Posts
Re: Designer Serialization Issue
May 31, 2006 12:27 PM|LINK
Tab Page looks ( and looked like this when i posted the problem )
[ToolboxData("\n<{0}:TabPage runat=\"server\">\n\t<TabBody>\n\t</TabBody>\n</{0}:TabPage>")]
[ParseChildren(true, "TabBody")]
[PersistChildren(false)]
[DefaultProperty("Title")]
//[Designer(typeof(TabPageDesigner))]
public class TabPage : PlaceHolder, INamingContainer
Tab Controol looks like this
[ParseChildren(true, "TabPages")]
[ToolboxData("<{0}:TabControl runat=\"server\">\n\t<TabPages>\n\t</TabPages>\n</{0}:TabControl>")]
[PersistChildren(false)]
[Designer(typeof(TabControlDesigner))]
public class TabControl : CompositeControl, ICallbackEventHandler
So... if i use the property window on tabcontrol,l i get a collection field of tabpages, which i can use to add a tabpage (or many).
the tabpage is added, but it does not get the <tabbody> tag.
Dragging into the source view directly does output correctly though.
http://www.Jonavi.com
http://www.jonavi.com/Default.aspx?pageID=21
http://RainbowBeta.com
http://community.rainbowportal.net/blogs/jonathans_rainbow_blog/default.aspx
http://dotnetslackers.com/community/blogs/jminond/default.aspx