is it possible to persiste customize object in view state?
how it is?
Answer Posted / 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 |
Post New Answer View All Answers
How can we update records in gridview?Is there any appropriate code for it?
Can we use a static function with a non-static variable?
What are the advantages of asp.net?
How can you enable impersonation in the web.config file?
Why we use content place holder in asp.net?
how to transfer the file from client to server using asp.net
What are cookies in your browser?
If you want to write your own dot net language, what steps you will you take care?
Which protocol is used to call a web service?
How to disable validator control by client side JavaScript?
What does session_start () do?
Explain one critical mapping?
How do I debug an asp.net application that was not written with visual studio.net and that does not use code-behind?
Which namespace is used by ado.net?
Difference between .NET and previous version?