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

What are sessions used for?

550


Which Is Faster MVC or ASP.net ?

577


Does web services support data reader like pom project?

524


How to do state management in ASP.NET?

595


What does asp.net stand for?

534






What is the server of asp.net?

504


If you want to bind the columns manually within the asp:datagrid tags what kind of tags you have to add.

616


Define repository pattern in mvc.net? : asp.net mvc

509


Differentiate between namespace and assembly.

557


What is the compiled object?

1635


Why is an object pool required?

603


Is it possible to develop a single web application using ASP.NET webforms and ASP.MVC?

592


Explain about asp.net 2.0 themes?

551


Can a .net web application consume java web service?

510


Using code explain Configuration Management

1404