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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / raovarinder singh

Yes it is possible to persiste customize object in view
state, Supposed your are having one variable named x for
which you want to persist the view state.

dim x as integer
ViewState(Value) = x

Which can then be accessed as follows:

x = ViewState(Value)

Is This Answer Correct ?    0 Yes 2 No

Post New Answer

More ASP.NET Interview Questions

Distinguish between Server-side and Client-side code?

0 Answers   Siebel,


Where is asp.net session stored?

0 Answers  


List of interview questions collections at www.dpoint.weebly.com

2 Answers   IBM,


If you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?

1 Answers  


How do you open a page in a new window?

0 Answers  






what are the main advantage in .net?

4 Answers   TCS,


What is the use of SmartNavigation property?

4 Answers  


What is a query string in a url?

0 Answers  


What base class do all Web Forms inherit from?

2 Answers   Siebel Systems,


what is diffrence between debug class and trace class in asp.net ?

2 Answers  


What is the difference between Session and response.Redirect?

0 Answers   Microsoft,


How Response.flush works in server.Execute

1 Answers  


Categories