is it possible to persiste customize object in view state?
how it is?
Answers were Sorted based on User's Feedback
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 |
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 |
Distinguish between Server-side and Client-side code?
Where is asp.net session stored?
List of interview questions collections at www.dpoint.weebly.com
If you want a certain ASP.NET function executed on MouseOver for a certain button. Where do you add an event handler?
How do you open a page in a new window?
what are the main advantage in .net?
What is the use of SmartNavigation property?
What is a query string in a url?
What base class do all Web Forms inherit from?
what is diffrence between debug class and trace class in asp.net ?
What is the difference between Session and response.Redirect?
How Response.flush works in server.Execute