Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > ASP.net 2.0 Custom Web Control Problem "could not be set on property "

Reply
Thread Tools

ASP.net 2.0 Custom Web Control Problem "could not be set on property "

 
 
Adam Rogas
Guest
Posts: n/a
 
      09-14-2004
I am having a problem with a property that is a collection. This is
only happening in design time but If I add the control to a page and
then use the properties window collection editor to add items to the
Buttons property, my collection, it renders in design time correctly;
however if after I have done that I switch to code view and then
switch back to design view it renders the control as an error and has
a tool tip of "'ListSelectBox' could not be set on property 'Buttons'"


I have included the code below, and I have tried every thing I can get
my hands on to remedy the problem. Any assistance would be much
appriciated.


#region Using directives

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Text;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.WebControls;

#endregion

namespace Controls
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:ListSelectBox
runat=server></{0}:ListSelectBox>")]
[ParseChildren(true)]
[PersistChildren(false)]
public class ListSelectBox : WebControl
{
// protected override void AddParsedSubObject(object obj)
// {
// if (obj is ListSelectBoxButton)
// {
// this.m_buttons.Add((ListSelectBoxButton)obj);
// return;
// }
// }

private string m_header;
private ButtonsCollection m_buttons = new ButtonsCollection();
[Bindable(true)]
[Category("Appearance")]
[DefaultValue("")]
public string Header
{
get
{
return m_header;
}

set
{
m_header = value;
}
}

[Category("Appearance")]
[DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
[PersistenceMode(PersistenceMode.InnerProperty)]
[NotifyParentProperty(true)]
public ButtonsCollection Buttons
{
get
{
return m_buttons;
}
set
{
m_buttons = value;
}
}

protected override void Render(HtmlTextWriter output)
{
output.Write(

@"<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td class=""StaticSelectBoxHeader"">Website Sections<td>
</tr>
<tr>
<td class=""StaticSelectBoxButtons"" align=""right"">");

foreach (ListSelectBoxButton Button in m_buttons)
{
Button.RenderControl(output);
}


output.Write(@"<td>
</tr>
<tr>
<td class=""StaticSelectBoxScroll"" onselectstart=""return false;""
><div class=""StaticSelectBoxScrollDiv"" style=""width:" +

this.Width.ToString() + @";height:" + this.Height.ToString() + @""" >
<table width=100% cellpadding=0 cellspacing=0 border=0>");

output.Write(@" <tr><td
class=""StaticSelectBoxItem"" onclick=""alert('Item Selected')"">This
is a test</td></tr>");

output.Write(@" </table>
</div><td>
</tr>
</table>");
}
}


[ToolboxData("<{0}:ListSelectBoxButton runat=server />")]
[ParseChildren(false)]
[PersistChildren(false)]
public class ListSelectBoxButton :
System.Web.UI.WebControls.Button
{


}

public class ButtonsCollection :
System.Collections.Generic.Collection<ListSelectBo xButton>
{

}
}
 
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
<value> could not be set on property <property name> TonyDyer General Computer Support 0 02-14-2012 03:25 PM
Custom control with complex property type (System.Web.UI.Control[]) Jeremy Chapman ASP .Net Building Controls 0 02-15-2006 06:00 PM
How to have a control stored in a property for a custom web control? Henrik Grotle ASP .Net Web Controls 0 09-09-2003 09:53 AM
'property value' could not be set on property 'propertyname' KJ ASP .Net Web Controls 0 08-26-2003 06:08 PM
ControlDesigner not invoked on custom control when control is rendered within another custom control Matt Sokol ASP .Net Building Controls 2 08-07-2003 07:13 AM



Advertisments