2011-12-15 5 views
3

사용자 지정 컨트롤 (4.0)을 개발 중이며 다시 작성하지 않고 비즈니스 클래스를 속성으로 다시 사용하는 방법을 알고 싶습니다.복잡한 속성을 사용하는 ASP.NET 사용자 지정 컨트롤

내가 (간체) 내 비즈니스 계층 어셈블리에서 클래스의 집합을했습니다 :

public class LatLng 
{ 
    public decimal Lat { get; set; } 
    public decimal Lng { get; set; } 
} 

public class MapOptions 
{ 
    ... 
    public LatLng Center { get; set; } 
    ... 
} 

etc... 

내가 원하는 것은 속성으로하는 MapOptions 클래스를 재사용하는 것입니다, 내 사용자 지정 컨트롤은 뭔가 같은 :

public class MyControl : WebControl 
{ 
    [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)] 
    public MapOptions MapOptions 
    { 
     ... 

     get 
     { 
      return this.ViewState["MapOptions"] as MapOptions; 
     } 
     set 
     { 
      this.ViewState["MapOptions"] = value; 
     } 

     ... 
    } 
} 

그러나이 방법으로 MapLptions 태그의 내부 섹션으로 LatLng (및 MapOptions의 속성으로 사용되는 다른 클래스)의 속성을 볼 수 없습니다. 오직 속성으로.

<rec:MyControl ID="control1" runat="server" Width="900" Height="500"> 
    <MapOptions> 
     <Center Lat="12.0" Lng="2.0" /> 
    </MapOptions> 
</rec:MyControl> 
:
<rec:MyControl ID="control1" runat="server" Width="900" Height="500"> 
    <MapOptions Center="" /> 
</rec:MyControl> 

그러나

내가 LatLng에 의해 노출 모두에 대한 인텔리을 잃고 이런 식으로, 나는이를 얻을 수있는 솔루션을 찾고 있어요 : 그래서 마크 업에 내가 쓸 수 있어요

제안 사항이 있으십니까?

답변

0

를 추가해보십시오 태그 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content), PersistenceMode(PersistenceMode.InnerProperty)] public class LatLng

관련 문제