Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Problem storing Style in View State

 
 
Rob
Guest
Posts: n/a
 
      07-18-2003
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"),
PersistenceMode(PersistenceMode.InnerProperty),
NotifyParentProperty(true),
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">
<VALIDATIONERRORSTYLE cssclass="testing"></VALIDATIONERRORSTYLE>
</SIERRACONTROL:LABELEDTEXTBOX>

but if I remove the tag and have this:

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

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
error.

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
via:

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

and they work fine too.
 
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
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



Advertisments