c# - Complex type inside custom control in ASP.NET 4.0 -


how can setup complex property inside custom control, have tried following. problem can't access complex property inside custom control class.

example custom control code:

public class mycustomcontrol : control, istylesheet {         [             bindable(true),             category("appearance"),             defaultvalue(""),             description("fullname"),             designerserializationvisibility(designerserializationvisibility.content),             persistencemode(persistencemode.innerproperty),         ]         public fullname myfullname {get; set;}          protected override void render(htmltextwriter writer)         {             // want access myfullname .aspx here         } }  public class fullname {     public string firstname {get; set;}     public string lastname {get; set;} } 

.aspx markup

<namespace:mycustomcontrol runat="server"">     <myfullname firstname="abc" lastname="def" />  </namespace:mycustomcontrol> 

i'm assuming not able values of firstname/lastname property set in markup inside render method of custom control.

try this article. excerpts article, applied situation below.

the myfullname property , properties of myfullname class need design-time attributes enable persistence within control's tags, shown in following example:

 <aspsample:mycustomcontrol >       <myfullname firstname="jody" lastname="foster" />     </aspsample:mycustomcontrol> 

the mycustomcontrol control stores simple properties in viewstate dictionary. however, mycustomcontrol control has implement custom state management fullname property manage state of property across postbacks.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -