|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
extended Label webcontrol, doesn't populate it's children ??I am extending couple of existing controls in ASP.NET like LinkButton, Label, TextBox etc.. I require these controls to contain a child control of MyControlType so ideally in HTML view for a label <asp:Label id="" [other properties...] > <cc1:MyControlType id="" [other properties...] /> <cc1:MyControlType id="" [other properties...] /> <cc1:MyControlType id="" [other properties...] /> </asp:Label> this kind of a thing should happen. So all my extended classes are decorated with PArseChildren(false, <Property>) It works fine for LinkButton. when I check LinkButton.Controls it now has the MyControlType populated. However, for a Label it doesn't work. Whenever i include a MyControlType within the label, Label's TEXT property gets empty and controls.count remains ZERO. Why ? Is this by design? (which means I won't be able to have nested controls for Label, TextBox etc.. ?) Any help is appreciated KK KK,
first, the label control's text property is set during the AddParsedSubObject method internally...and only LiteralControl's are used to populate the .Text property, hence the .Text property being zero'd out. second, it is possible to nest controls within a label, such as: <asp:Label id="lblFoo" runat="server"> <asp:Textbox id="txtFoo1" runat="server"/> <asp:Textbox id="txtFoo2" runat="server"/> </asp:Label> since you're using a custom control namespace, do you have runat="server" on each tag? if so, what html source is being rendered, if any, between the <span></span> tags for the label? it sounds like you need exact control over what controls are children of the label. since you cannot change the behavior of the stock label control while still referencing it as asp:label, i would recommend writing your own custom control. for example, if you built a custom control that derived from Label, you could override the AddParsedSubObject method which will give you strict control as to how it handles the controls it parses. if you need even further support, you could even write your own ControlBuilder to allow parsing custom tags. let me know if you're still having issues, Mike MacMillan KK wrote: Show quoteHide quote > Hi, > > I am extending couple of existing controls in ASP.NET > like LinkButton, Label, TextBox etc.. > > I require these controls to contain a child control of MyControlType > so ideally in HTML view for a label > > <asp:Label id="" [other properties...] > > <cc1:MyControlType id="" [other properties...] /> > <cc1:MyControlType id="" [other properties...] /> > <cc1:MyControlType id="" [other properties...] /> > </asp:Label> > > this kind of a thing should happen. So all my extended classes are > decorated with PArseChildren(false, <Property>) > > It works fine for LinkButton. when I check LinkButton.Controls it > now has the MyControlType populated. However, for a Label it doesn't > work. Whenever i include a MyControlType within the label, Label's TEXT > property gets empty and controls.count remains ZERO. Why ? > > Is this by design? (which means I won't be able to have nested controls for > Label, TextBox etc.. ?) > > Any help is appreciated > > KK
Event Sequence
ReportViewer/ObjectDataSource Problem objectdatasource.update() fires System.InvalidOperationException THEAD DropDownList not giving the selected item when a Button is clicked... please help newbie... Wizard Control and IsPostBack Styling DetailView or FormView Click event handler not called on dynamically create image button GridView: Update is just not working for me How to determine the "state" of a GridView |
|||||||||||||||||||||||