is it possible to persiste customize object in view state?
how it is?

Answer Posted / satish v itagi

You have to use <Serializable()> attribute prefixed to the
class declaration before you keep object of this class in
viewstate. However, larger the object, slower will be
performance. There will be risk of viewstate getting
corrupted.

Eg
'' in class definiton:
<serializable()> Public Class Fruit
private sName as string
public sub new(ByVal Name as string)
sName = Name
End Sub
readonly property Name as string
Get
return sName
end get
End Class

''in code behind:
if page.ispostback = false
dim MyApple as new Fruit("Kashmiri Apple")
ViewState("oMyFruit") = MyApple
end if

'' In button click
label1.text = ctype( ViewState("oMyFruit") , Fruit).Name

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is asp.net mvc still used? : Asp.Net MVC

597


What is viewstate in asp net with example?

610


If 200 is for all successful operation then why do we have 201 response codes?

618


Why we are using mvc instead of asp.net? : Asp.Net MVC

603


What is the postback property in asp.net?

626






What is the difference between trace and debug in asp.net?

714


How to register exception filter globally?

687


Is post back property in asp net?

625


How do u deploy ur project?

2305


Which protocol is used to call a web service?

663


What’s the difference between response .redirect and server.transfer?

602


What is cache in asp net?

623


What is the displayafter property in updateprogress control?

607


What is app_code folder in asp net?

626


What threading model used in asp and asp.net?

650