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 |
Why do we need Web Services?
Page Life Cycle in ASP.NET
What are different types of authentication techniques that are used in connection strings to connect .net applications with microsoft sql server?
What is a web server? What are the load limits in it?
What are asynchronous callbacks ?
6 Answers Accenture, BirlaSoft,
What are the session variables?
What is a PostBack? What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState? Why is it either useful or evil?
If you want to bind the columns manually within the asp:datagrid tags what kind of tags you have to add.
Define ViewState and how can it be used?
version information is mentioned in which file
What are the benefits of view state?
How do you specify whether your data should be passed as Query string and Forms (Mainly about POST and GET)