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

I have a webform in asp.net.In that webform there is 2 division class(DIV).in one of the div class there is a text box for enter the id & a button for to check id with database value.My doubt is that how can i appear the 2nd Div contents only when the id is true with database value.if wrong do not display the div . i Want code in c#.

2 Answers  


Which property on a Combo Box do you set with a column name, prior to setting the DataSource, to display data in the combo box?

2 Answers   Siebel Systems,


You need to retrieve data from a Microsoft SQL Server 2000. Currently you are using an oleDbConnection object to connect to the database server. You need to be able to retrieve the data from the database server in XML format. Which approach would be the most efficient? Select all that apply. Each answer constitutes part of the whole answer. a) Change to the SQL .NET provider. b) Use the ExecuteXmlReader() method of the xxxCommand object c) Use the DOM to create the XML document. d) Use the XmlDocument.Load() method to create the XML Document.

1 Answers   Syntax Softtech,


which is best possible way to add data source to data grid when the data is huge(10 lack recored)how to edit a perticular row

3 Answers   Airtel, Aviva,


What does uri mean?

0 Answers  


Suppose you want an asp.net function (client side) executed on the mouseover event of a button. Where do you add an event handler?

0 Answers  


Can action method static?

0 Answers  


how can you bind data from dataset to XML file

2 Answers   LG Soft,


AJAX - explain the concept and some controls like update panel, tabcontrol etc

2 Answers   Syntel,


what is narmalization

4 Answers   Wipro,


What will happen if the server confugration file and the application confugration file have different values for sassion state ASP.NET?

0 Answers   HCL,


What is a response cookie?

0 Answers  


Categories