CompositeControl - Value could not be set on Property

Hello everyone,

I am working on a composite control and I have a public property called ButtonText:


[DefaultValue("Get an Image")]
[Description("The text for the button"]
public string ButtonText
  return _btnGetImage.Text;
  _btnGetImage.Text = value;

private Button _btnGetImage;

public ITemplate ItemTempalte { get; set; }

protected override void CreateChildControls()
if(_ItemTemplate != null && DesignMode)

Everything works fine up until i convert the control to a template, once I convert it to tempalte I get an error message saying:
'Get an Image' could not be set on property 'ButtonText'.

Can anyone please tell me what is going on? I've spent hours trying to figure out this thing.

5/1/2009 3:39:24 PM 3498 articles. 0 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 33


Could you tell me how to reproduce this exception?

once I convert it to tempalte

How do you do this?

Allen Chen
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
5/4/2009 6:31:31 AM

Hey Allen,

 In the visual studio (design time) I hover over the control and select the smart tag > convert to template

 Same way you would convert an ASP.NET LoginControl etc into template. Please let me know if anything else needs clarification. 


5/4/2009 3:54:08 PM

Similar Artilces:

Set up property editors for a custom server control
I built a custom web server control which has a FormView property. When I drop the control on a web form, the FormView property is visible in the designer. Its value shows 'None' and the dropdownlist for this property is empty. The dropdownlist should contain all FormView controls which are on the web form. How can I fill the dropdownlist in the designer with all FormView controls? Now I cannot edit the property with anything, although the FormView property has a setter. Should I mark the property with some kind of attribute? Nils GrusonMicrosoft .NET Consultant (MCPD)LogicaYou don&#...

Custom Server Control
 Hello everybody, I'm building a server control that derives from TextBox that will include validators along with it.The problem that I'm facing now is the properties assigment. Placing the control in a web form, and setting the properties in the designer (not in the Form Designer but in the HTML designer) causes the control to not take the values of the properties. 1 <!-- Default.aspx --> 2 <tr> 3 <td style="text-align:right;">Quantity:</td> 4 <td> 5 <!-- Integer Validation --> 6 ...

Using Enums to set Custom Server Control Properties
Hi All.I have a rather large project I'm working on. We have a custom control that basically ends up to be a dropdown. This custom control have 3 public properties that are Enums, which are defined in a seperate class libary. We are using the custom control in many of our User controls, which all inherit from a "BaseUserControl" class. We want the developers to be able to use our custom control and set the three enums values in the source part of the ascx file. Then we want to define a method in the "BaseUserControl" that will load data into the dropdown from the data...

Property is not setting in custom control property
hi ,         I am adding an image control programmatically in a webpartzone which is adding successfully but the properties i am setting in image control are not setting .following is the code that i am using .the code 'img.ImageUrl = "~/images/atlas_title.jpg"     do not set the property in it.Dim webmgr As WebPartManager = WebPartManager.GetCurrentWebPartManager(Me)Dim img As New Web.UI.WebControls.Imageimg.ID = "Img"'img.ImageUrl = "~/images/atlas_title.jpg"     ...

How to create custom properties for aspx page which should refelect in design time properties window itself.( as like as custom server control).
Hi. I need to create the custom properties for aspx page itself where those custom properties should refelet in the properties window at the design time as like as other custom server controls. I tried pageBase class which will have cusom properties for page and inherited that pageBase to my aspx page . But its refelecting the code  behind file not in design time. I need to accss those aspx page custom properties at the design time itself in properties window as like as other custom server control.I appriciate your help. [FYI: my scenerio is customer ...

custom property style for a custom server control
Can I add a proerty for style on my asp .net custom server control, seems to be one for everything else. Or do you have to go do one style at a time: backgroundColor, Font, etc....

adding custom properties to a custom server control
1.  I want to add a public property to a custom server control.  the property is called Search Type and the possible choices that will appear in the properties window from the page would be client, provider, vendor and service.  I want this property to function much like the border style property works for an button. 2.  My second question would be how do I add a section to the properties window?  What i mean is for this custom server control, i want to add a section called Search Features much like the appearance or behavior sections for an ...

Usercontrol vs Custom Server Controls, Any need for Custom Server Controls
Hello I'm new to ASP.Net so this is probably a stupid question but, is there any need to create customer server controls now that you can pre-compile usercontrols into a dll and thus easily share between applications? This blog post from David Ebb describes how to do it and the restrictions he note don't seem that bad (other than being able to embed resources such as images in the dll). His article desribes the techniques for ASP.Net 2.0 and he suggests that there will be further improvements in .Net 3.5 in this ar...

Custom Server Control Vs Web Parts, Any need for Custom Server Control
Hello I've just posted a similar question on why you need server controls when you can pre-compile usercontrols and redistribute them. I've seen lots of (usercontrol vs web part) but not much on web part vs custom server control. According to the MSDN site you can put web parts onto a normal page outside of a web part zone and they behave just like custom server controls. So, if you are creating a bunch of controls for redistribution to customer sites and/or SharePoint sites why don't you just create Web Par...

problems listenening to events on a custom server control from another custom server control
 Hi all,I am having problems listening to events on one of custom server controls(AddBookmark) from another custom server control(BookmarkList). The listener or the BookmarkList control has a property that can be set to the AddBookmark control (string at design but the reference is obtained at run-time). I am able to get a reference to the AddBookmark control and add a listener to it on the BookmarkList control on the OnPrender of BookmarkList. But the problem is that when the events on AddBookmark gets fired, the listener added from the BookmarkList is no longer present and the listene...

Custom Server Control Design Time Property Shows "Object reference not set to an instance of an object"
The property "ReferenceValue" from my code below keeps showing an error in the properties window as above. The control however functions perfectly otherwise. 1 Imports System 2 Imports System.Web 3 Imports System.Web.UI 4 Imports System.Web.UI.WebControls 5 Imports Capr.Web.UI.ControlInterfaces 6 7 8 Namespace Controls 9 10 Public Class WMSTextBox 11 Inherits System.Web.UI.WebControls.TextBox 12 Implements ICaprBaseControl 13 14 Public Sub New() 15 End Sub 16 17 Public P...

Creating .Net custom server controls and .Net pages programatically
Thanks a lot for reading this and greatly appreciate your inputs I am writing a webinterface that lets users configure options that'll create an interface for them and generete the webpage. So I am having to programattically create custom server controls and .Net page with code behind to support the functionality. Are there APIs in the .NET SDK that let you do this. Any pointers would be greatly helpful Thanks a lot Sathya Controls on the fly? Or Create code on the fly? I think it is the latter so here we go - look at the following namespaces: * System.Reflection.Emit - gen...

Custom server control with databound property failing to rebuild controls...
Hi, I've written a custom server control (radiobuttonlist) which has a property that is populated by a databound parent control (ie the value is passed through when the parent control is data bound). The custom server control creates it's contents based on the value that is passed. This works ok on the first creation as I use the Render method to populate the control, but when a command (save) is called on the parent control, the render method is not called and the custom control doesn't populate. I've tried many different ways to do what I need to do but all attem...

Custom Server Control Made of Custom Controls?
I'm giving myself a crash course in custom server controls, and I have a quick general question. Can I have a custom server control that is composed of other server controls I created. I'm pretty sure the answer is yes, but I want to be positive. Yes Shows how to combine existing controls into a new control using class composition. -ron Thanks! ASP.NET so rocks! Making page components extensible objects is such a great idea! I love it....

Custom UI Control losing information of nested controls upon Set of some its properties
 Hi there, I have created a custom web control, aptly name MyLinkButton. The ascx looks like this:<asp:LinkButton ID="lnkLinkButton" runat="server" OnClick="lnkLinkButton_Click" OnCommand="lnkLinkButton_Command">    <span>        <asp:Literal ID="ltlLinkText" runat="server" />    </span></asp:LinkButton> When you set any of it's properties, it internally sets the property of the lnkLinkButton control with the exception o...

Web resources about - CompositeControl - Value could not be set on Property -

Scott Banwart - .NET - Scott Banwart
Scott Banwart - The Rogue Technologist About Me .NET BizTalk Books Business Cloud Development Distributed Weekly Integration Linux Meta Ruby ...

Resources last updated: 12/3/2015 3:27:24 PM