![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi, I've been learning how to create custom web controls and have been having problems with subproperties. The first problem is that you can not see subproperties using intellisense. You can type the subproperty attribute in the tag and it will render correctly, but the source view of the page shows a validation error. For example: cc1:SubPropertyExample runat="server" textbox-text="Some sample text" / correctly sets the attribute of the sub property, but I get a validation error. Intellisense does not show Textbox-Text as an option. The second issue is that changes made to the property in design view do not stick. If I set the Text property of the Textbox in design view the changes are lost as soon as I switch to source view. Below is a stripped-down sample control that illustrates the problem. If anyone can tell me what I'm doing wrong I'd appreciate it. Justin [ToolboxData("<{0}:SubPropertyExample runat=server></{0}:SubPropertyExample>")] public class SubPropertyExample : CompositeControl { private TextBox textbox; public SubPropertyExample() : base() { } [ Category("Behavior"), Bindable(true), Localizable(true), NotifyParentProperty(true) ] public TextBox TextBox { get { CreateTextBox(); return textbox; } } protected override void CreateChildControls() { base.CreateChildControls(); this.CreateTextBox(); } protected override void RenderContents(HtmlTextWriter output) { } private void CreateTextBox() { if (textbox == null) { textbox = new TextBox(); textbox.ID = this.GetType().Name; } } } |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
Adding [DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)] to the property fixed the Intellisense problem. Overriding the text property in an inherited control did not fix the issue with values set from the designer not persisting. I'm still not sure what's going on with this. Thanks for the help, Justin |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |