W
wjfamilia
When I make a custom server control that inherits from ListControl or the
other similar controls (DropDownList, CheckBoxList, etc.), I cannot get the
child <asp:ListItem> control to show with the Visual Studio 2005
intellisense. The control does render the correct results and you can even
stop the build warning by wrapping the <asp:ListItem> children in
<Items></Items>, BUT there is no intellisense! Why? What is needed to make my
custom control's intellisense work like the ListControl's intellisense?
Here is the custom control code I have up until now:
//Custom
CheckBoxControl:////////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NSP.Web.UI.WebControls
{
[AspNetHostingPermission(SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
[ParseChildren(true, "asp:ListItem")]
public class CheckBoxList : System.Web.UI.WebControls.CheckBoxList
{
[DefaultValue((string)null)]
[Category("Default")]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("The collection of items in the list.")]
[Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.Design,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor))]
[MergableProperty(false)]
public override ListItemCollection Items
{
get { return base.Items; }
}
[Bindable(true)]
[Category("Data")]
[DefaultValue("")]
[Localizable(true)]
public string CmsKey
{
get
{
string s = (string)ViewState[this.ID + "CheckBoxListCmsKey"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState[this.ID + "CheckBoxListCmsKey"] = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
}
}
}
//Implementation on Web
Form////////////////////////////////////////////////////////
<nsp:CheckBoxList ID="chklOptionPicker" runat="server">
<asp:ListItem Text="Option #1" Value="1"></asp:ListItem>
<asp:ListItem Text="Option #2" Value="2"></asp:ListItem>
<asp:ListItem Text="Option #3" Value="3"></asp:ListItem>
</nsp:CheckBoxList>
This topic has been addressed on other forums, but no solution has been
published.
- http://forums.asp.net/t/1151562.aspx
- http://forums.asp.net/t/979255.aspx
Please help!
--
William J. Familia
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/communitie...blic.dotnet.framework.aspnet.buildingcontrols
other similar controls (DropDownList, CheckBoxList, etc.), I cannot get the
child <asp:ListItem> control to show with the Visual Studio 2005
intellisense. The control does render the correct results and you can even
stop the build warning by wrapping the <asp:ListItem> children in
<Items></Items>, BUT there is no intellisense! Why? What is needed to make my
custom control's intellisense work like the ListControl's intellisense?
Here is the custom control code I have up until now:
//Custom
CheckBoxControl:////////////////////////////////////////////////////////////////
using System;
using System.ComponentModel;
using System.Collections;
using System.Drawing.Design;
using System.Security.Permissions;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace NSP.Web.UI.WebControls
{
[AspNetHostingPermission(SecurityAction.LinkDemand, Level =
AspNetHostingPermissionLevel.Minimal),
AspNetHostingPermission(SecurityAction.InheritanceDemand, Level =
AspNetHostingPermissionLevel.Minimal)]
[ParseChildren(true, "asp:ListItem")]
public class CheckBoxList : System.Web.UI.WebControls.CheckBoxList
{
[DefaultValue((string)null)]
[Category("Default")]
[PersistenceMode(PersistenceMode.InnerProperty)]
[Description("The collection of items in the list.")]
[Editor("System.Web.UI.Design.WebControls.ListItemsCollectionEditor,System.Design,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
typeof(UITypeEditor))]
[MergableProperty(false)]
public override ListItemCollection Items
{
get { return base.Items; }
}
[Bindable(true)]
[Category("Data")]
[DefaultValue("")]
[Localizable(true)]
public string CmsKey
{
get
{
string s = (string)ViewState[this.ID + "CheckBoxListCmsKey"];
return ((s == null) ? String.Empty : s);
}
set
{
ViewState[this.ID + "CheckBoxListCmsKey"] = value;
}
}
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
}
}
}
//Implementation on Web
Form////////////////////////////////////////////////////////
<nsp:CheckBoxList ID="chklOptionPicker" runat="server">
<asp:ListItem Text="Option #1" Value="1"></asp:ListItem>
<asp:ListItem Text="Option #2" Value="2"></asp:ListItem>
<asp:ListItem Text="Option #3" Value="3"></asp:ListItem>
</nsp:CheckBoxList>
This topic has been addressed on other forums, but no solution has been
published.
- http://forums.asp.net/t/1151562.aspx
- http://forums.asp.net/t/979255.aspx
Please help!
--
William J. Familia
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.
http://www.microsoft.com/communitie...blic.dotnet.framework.aspnet.buildingcontrols