|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Custom Collection Property Persistenceproperty that is the type of another control. I believe I have all the necessary atttributes set on the class and property (peristence, parsechildren, etc...) but it still does not work properly. I can access the property in the designer just fine and add new control instances, but when I close the property window none of the controls I just created are persisted into the HTML. To recreate the problem I created a very simple server control that demonstrates the behavior. The code is as follows: Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.ComponentModel Imports System.ComponentModel.Design Imports System.Drawing <ToolboxData("<{0}:ServerControlTest runat=server></{0}:ServerControlTest>"), _ ParseChildren(True)> _ Public Class ServerControlTest Inherits CompositeControl Private moLabels As List(Of Label) <Browsable(True), _ Category("Appearance"), _ Description("The ribbon groups for this tab."), _ PersistenceMode(PersistenceMode.InnerProperty), _ DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _ Public ReadOnly Property Labels() As List(Of Label) Get Return moLabels End Get End Property #Region "Rendering" Protected Overrides Sub CreateChildControls() MyBase.CreateChildControls() Controls.Clear() CreateControlHierarchy() ClearChildViewState() End Sub Protected Sub CreateControlHierarchy() Me.Width = Unit.Pixel(200) Me.Height = Unit.Pixel(200) ' make sure we have controls to put in the content If Not moLabels Is Nothing Then For Each rb As Label In moLabels Me.Controls.Add(rb) Next End If End Sub Protected Overrides ReadOnly Property TagKey() As System.Web.UI.HtmlTextWriterTag Get Return HtmlTextWriterTag.Div End Get End Property #End Region End Class If you try and use the "Labels" property in design mode you will see that none of the labels added are properly persisted. Can anyone please tell me why???
Need some advice on a GridView control.
Events for programatically added controls Menu control. Clickable area Custom Server Controls and javascript Exposing an event handler as a control property Add control to TreeView (ASP.NET 2.0) Clikable rows in Grid View Using Gridview To Export Data To Excel Error (ASP.NET 2.0) Master Page Where in the page lifecycle does validation occur? |
|||||||||||||||||||||||