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

Why do we need Web Services?

1 Answers   Mind Tree,


Page Life Cycle in ASP.NET

2 Answers   Syntel,


What are different types of authentication techniques that are used in connection strings to connect .net applications with microsoft sql server?

0 Answers  


What is a web server? What are the load limits in it?

0 Answers   Wipro,


What are asynchronous callbacks ?

6 Answers   Accenture, BirlaSoft,






What are the session variables?

0 Answers  


What is a PostBack? What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? Why is it either useful or evil?

3 Answers   TCS,


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

0 Answers   Siebel,


Define ViewState and how can it be used?

6 Answers   Siebel,


version information is mentioned in which file

3 Answers   AG Technologies,


What are the benefits of view state?

0 Answers  


How do you specify whether your data should be passed as Query string and Forms (Mainly about POST and GET)

2 Answers  


Categories