[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Custom ListControl has no VS intellisense for

wjfamilia

8/31/2007 8:18:00 PM

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/11...
- http://forums.asp.net/t/9...

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/communities/newsgroups/list/en-us/default.aspx?mid=a537ab57-1e9e-43b7-83c3-5c896d4287a8&dg=microsoft.public.dotnet.framework.aspnet.buildi...
2 Answers

Teemu Keiski

9/1/2007 1:44:00 PM

0

Issue simply is that asp:ListItem is ListItem class in
System.Web.UI.WebControls namespace. It's a limitation in VS2005 that the
items related to a control should exist in same namespace. E.g type of the
Items property and the ListItem itself should be their own types (ListItem
is sealed so it requires writing it from scratch)

I've blogged about it in the past:
http://aspadvice.com/blogs/joteke/archive/2006/01/27/...

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice....
http://teemu...


"wjfamilia" <wjfamilia@discussions.microsoft.com> wrote in message
news:A537AB57-1E9E-43B7-83C3-5C896D4287A8@microsoft.com...
> 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/11...
> - http://forums.asp.net/t/9...
>
> 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/communities/newsgroups/list/en-us/default.aspx?mid=a537ab57-1e9e-43b7-83c3-5c896d4287a8&dg=microsoft.public.dotnet.framework.aspnet.buildi...


Teemu Keiski

9/1/2007 1:46:00 PM

0

To add, of course you could put your own control to
System.Web.UI.WebControls namespace but I think MS doesn't recommend that
approach.


--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice....
http://teemu...



"wjfamilia" <wjfamilia@discussions.microsoft.com> wrote in message
news:A537AB57-1E9E-43B7-83C3-5C896D4287A8@microsoft.com...
> 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/11...
> - http://forums.asp.net/t/9...
>
> 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/communities/newsgroups/list/en-us/default.aspx?mid=a537ab57-1e9e-43b7-83c3-5c896d4287a8&dg=microsoft.public.dotnet.framework.aspnet.buildi...