Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Serialize Style to save ViewState

Reply
Thread Tools

Serialize Style to save ViewState

 
 
Alex
Guest
Posts: n/a
 
      03-16-2005
Hi,
I've the follow error:
"The type 'ViewStateControl.MyCollection' must be marked as Serializable or
have a TypeConverter other than ReferenceConverter to be put in viewstate."
MyCollection has the attributte Serializable(). MyCollection is a collection
of MyItem (Serializable()). If i remove the Property Style (Type
System.Web.UI.WebControls.Style), the error don't happend.
Somebody can help me?

Thanks


 
Reply With Quote
 
 
 
 
Brock Allen
Guest
Posts: n/a
 
      03-16-2005
If you want to store your own types (classes) in ViewState you need to mark
them with the Serializable attribute, which grants permission to store them
in the ViewState persistence medium.

[Serializable]
class MyCollection : SomeBase
{
}

Also, any items that go into the collection also need to be marked with the
Serializable attribute. BTW, it's <Serializable> in VB.NET.

-Brock
DevelopMentor
http://staff.develop.com/ballen



> Hi,
> I've the follow error:
> "The type 'ViewStateControl.MyCollection' must be marked as
> Serializable or
> have a TypeConverter other than ReferenceConverter to be put in
> viewstate."
> MyCollection has the attributte Serializable(). MyCollection is a
> collection
> of MyItem (Serializable()). If i remove the Property Style (Type
> System.Web.UI.WebControls.Style), the error don't happend.
> Somebody can help me?
> Thanks
>




 
Reply With Quote
 
 
 
 
Alex
Guest
Posts: n/a
 
      03-16-2005
I must create my own Style inherited from Style with Attribute
Serializable() ?



"Brock Allen" <_hate_spam_too> escribió en el mensaje
news:.. .
> If you want to store your own types (classes) in ViewState you need to
> mark them with the Serializable attribute, which grants permission to
> store them in the ViewState persistence medium.
>
> [Serializable]
> class MyCollection : SomeBase
> {
> }
>
> Also, any items that go into the collection also need to be marked with
> the Serializable attribute. BTW, it's <Serializable> in VB.NET.
>
> -Brock
> DevelopMentor
> http://staff.develop.com/ballen
>
>
>
>> Hi,
>> I've the follow error:
>> "The type 'ViewStateControl.MyCollection' must be marked as
>> Serializable or
>> have a TypeConverter other than ReferenceConverter to be put in
>> viewstate."
>> MyCollection has the attributte Serializable(). MyCollection is a
>> collection
>> of MyItem (Serializable()). If i remove the Property Style (Type
>> System.Web.UI.WebControls.Style), the error don't happend.
>> Somebody can help me?
>> Thanks
>>

>
>
>



 
Reply With Quote
 
Teemu Keiski
Guest
Posts: n/a
 
      03-25-2005
I dropped off the track how you have it currently, but here is a link to an
example howto save Style object to your control's Viewstate. Instead of
passing the style to ViewState straight, you use it's IStateManager
interface implementation to let the style itself save/load/track the state
and let the control put/take that state data to/from Viewstate and hand to
the style object.

Instead of passing the object to Viewstate, let it hand you the state, and
put only that state to Viewstate (saves CPU cycles as entire object doesn't
need to be serialized plus that Binary serialization is slow). Anyway here's
an example of a control I wrote which uses custom style and saves its data
to control's Viewstate

http://www.asp.net/Forums/ShowPost.a...&PostID=842466

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU



"Alex" <> wrote in message
news:%...
>I must create my own Style inherited from Style with Attribute
>Serializable() ?
>
>
>
> "Brock Allen" <_hate_spam_too> escribió en el mensaje
> news:.. .
>> If you want to store your own types (classes) in ViewState you need to
>> mark them with the Serializable attribute, which grants permission to
>> store them in the ViewState persistence medium.
>>
>> [Serializable]
>> class MyCollection : SomeBase
>> {
>> }
>>
>> Also, any items that go into the collection also need to be marked with
>> the Serializable attribute. BTW, it's <Serializable> in VB.NET.
>>
>> -Brock
>> DevelopMentor
>> http://staff.develop.com/ballen
>>
>>
>>
>>> Hi,
>>> I've the follow error:
>>> "The type 'ViewStateControl.MyCollection' must be marked as
>>> Serializable or
>>> have a TypeConverter other than ReferenceConverter to be put in
>>> viewstate."
>>> MyCollection has the attributte Serializable(). MyCollection is a
>>> collection
>>> of MyItem (Serializable()). If i remove the Property Style (Type
>>> System.Web.UI.WebControls.Style), the error don't happend.
>>> Somebody can help me?
>>> Thanks
>>>

>>
>>
>>

>
>



 
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
Serialize CommandEventHandler to ViewState? DC ASP .Net 2 04-15-2008 07:37 AM
Can viewstate serialize this class? Ben Amada ASP .Net 7 10-30-2005 07:35 PM
serialize to SQL Server Blob instead of XML serialize Gordz ASP .Net 3 06-07-2004 07:46 PM
serialize class to the viewstate Craig Buchanan ASP .Net 1 01-27-2004 10:06 PM
Serialize a class to viewstate? Manit Chanthavong ASP .Net Web Controls 0 01-07-2004 10:38 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57