Last post Aug 12, 2009 01:25 PM by BGRhoades
Aug 11, 2009 01:16 AM|mahmoud6901|LINK
I have a simple server-side control that is developed like this :
This control works fine in run-time and then it means it has no bug. Additionally, In design time, it works well in default mode and rendered correctly. But if I change the ImageType property, it fails (just in design-time). how can I fix it?
the sample design-time code is:
<SPS:Button runat="server" ID="btn"
onclick="btnAddBaseEntity_Click" Width="120px" ImageType="Remove">Remove Item</SPS:Button>
anyone can help?
server control designer properties
enumerations custom control
Aug 11, 2009 02:16 PM|RichardD|LINK
It sounds like the designer doesn't like automatic properties. Have you tried switching to a viewstate-backed property?
public ButtonImageTypes ImageType
return (ButtonImageTypes?)ViewState["ImageType"] ?? ButtonImageTypes.Save;
ViewState["ImageType"] = value;
Aug 12, 2009 12:58 AM|mahmoud6901|LINK
Thanks for your fast reply. I did your proposed changes but the same error was happend (error message is: error rendering control. an unhandled exception has occurred. ButtonImageTypes could not be set on property 'Check'). The misery is that this error
happens for each kind of user defined property!!!(String,Integer,...)... I think the source of error should be from somewhere else (Visual studio bug or forgetting to set an attribute).
I also should mention that I tried the following solutions but the output was same :
1- using common properties instead of automatic properties
2-removing all the attributes
3-trying to bgring the VS to debug mode to see what happened on "set" property. but none of "set" properties were fired.(just my breakpoints on "get" were captered)...I think this shows that the problem is happening at a stage before calling the "set" property.
Also it seems a VS 2008 SP1 bug.(check this :
http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=478158 ) but I couldn't find a way to resolve it there! any help?
Aug 12, 2009 01:25 PM|BGRhoades|LINK
Have you tried setting the property using the Enumeration Name?
<SPS:Button runat="server" ID="btn" onclick="btnAddBaseEntity_Click" Width="120px" ImageType="ButtonImageTypes.Remove">Remove Item</SPS:Button>