Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Problem storing Style in View State

Thread Tools

Problem storing Style in View State

Posts: n/a
I have created a custom control that has
System.Web.UI.WebControls.Style has a property.

The property is defined like this:

[Bindable(true), Category("Style"),
DesignerSerializationVisibility(DesignerSerializat ionVisibility.Content)]
public virtual Style ValidationErrorStyle {
get {
if (ViewState["VALIDATION_ERROR_STYLE"] == null)
ViewState["VALIDATION_ERROR_STYLE"] = new Style();
return (Style)ViewState["VALIDATION_ERROR_STYLE"];

Everything works great if I have a ValidationErrorStyle tag in the
aspx page, like this:

<SIERRACONTROL:LABELEDTEXTBOX id="SampleControl" runat="server">

but if I remove the tag and have this:

<SIERRACONTROL:LABELEDTEXTBOX id="SampleControl" runat="server">

I get a "The type 'System.Web.UI.WebControls.Style' must be marked as
Serializable or have a TypeConverter other than ReferenceConverter to
be put in viewstate." Exception.

I extended Style and created a SerializedStyle Class that I tried to
use. I marked the class [Serializable], implemented ISerializable and
the SerializableStyle, and GetObjectData methods. I still got the

I am at a complete loss here. Funny thing is if I replace Style with
TableItemStyle it works just fine. Also there are two other Style
properies in the control and they just reference internal controls

[Bindable(true), Category("Style"),
public virtual Style TextBoxStyle {
get { EnsureChildControls(); return txtBox.ControlStyle; }

and they work fine too.
Reply With Quote

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
User Images: Storing in Files VS Storing in Database Jonathan Wood ASP .Net 1 06-02-2008 05:56 PM
storing pointer vs storing object toton C++ 11 10-13-2006 11:08 AM
Storing a datatable in application or session state? Jason ASP .Net 6 11-01-2005 09:31 PM
How to make a week view and day view calendar just like month view calendar in .NET ? Parthiv Joshi ASP .Net Web Controls 1 07-06-2004 03:15 PM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM