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
What is asp.net used for?
What is strong-typing versus weak-typing?
Where viewstate value is stored in asp.net?
What is the difference between system.stringbuilder and system.string
What is the benefit of WebAPI over WCF?
Can you set which type of comparison you want to perform by the comparevalidator control?
What is the biggest disadvantage of “Other Return Types” in Web API?
Difference between singleton and singlecall.
What is Partial PostBack in ASP.NET?
How do http sessions work?
When maintaining session through sql server, what is the impact of read and write operation on session objects?
How does http session work?
Define the steps to set up validation control.
What is the difference between page directive include and action tag include?
What is a proxy in web service?