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

Whats the use of @ Register directives ?

4 Answers  


How do you design a website with multilingual support in ASP.NET ?

0 Answers   MCN Solutions,


What is the difference between dispose() and finalize()?

0 Answers  


What are Session states available and its Uses?

2 Answers   iLogic,


Explain what is event bubbling?

0 Answers  






is gateway for sms continue connected for sending sms.how?

0 Answers  


When does the application ONEND event handler fire?

1 Answers   C Squared Systems, Verinon Technology Solutions,


if i want to give an alert message like "try after sometime" to a web page which is being seen by other person.if a web page is not seen by anyone then it should display otherwise it show a display a message stating that other person is viewing so try after some time........how can i implement this.

0 Answers   Siemens,


I am using a range validator and want to use dd mm yyyy format for accepting dates. I get a fairly generic "can't do that" type exception when I use this format for setting the minValue or maxValue properties for the range validator. How can I force it to accept my format?

1 Answers   FutureTech,


What is server side session?

0 Answers  


How ASP and ASP.NET page works.

3 Answers  


what is asp.net

4 Answers  


Categories