Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Custom ListControl has no VS intellisense for <asp:ListItem>

Reply
Thread Tools

Custom ListControl has no VS intellisense for <asp:ListItem>

 
 
wjfamilia
Guest
Posts: n/a
 
      08-31-2007
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.Inheritance Demand, 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.ListItems CollectionEditor,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/communities...ildingcontrols
 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      09-01-2007
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/ar.../27/14886.aspx

--
Teemu Keiski
AspInsider, ASP.NET MVP
http://blogs.aspadvice.com/joteke
http://teemukeiski.net


"wjfamilia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Inheritance Demand, 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.ListItems CollectionEditor,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/communities...ildingcontrols



 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      09-01-2007
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.com/joteke
http://teemukeiski.net



"wjfamilia" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Inheritance Demand, 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.ListItems CollectionEditor,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/communities...ildingcontrols



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Custom ListControl OnFocus Event not working Scott Blood ASP .Net Building Controls 0 07-31-2006 10:04 AM
Inherit from a custom ListControl Chris Burge ASP .Net Web Controls 1 12-23-2005 08:28 PM
ListControl and Postback SK ASP .Net 0 02-15-2005 09:49 PM
listcontrol, checkboxlist, radiobuttonlist, placeholder Elad Volpin ASP .Net 3 07-18-2004 05:22 AM
Listcontrol on placeholder does not maintain state chak ASP .Net 1 08-23-2003 09:40 PM



Advertisments