How do you implement ViewState for a control?

In ASP.NET 4, Web server controls include a ViewStateMode property that lets you disable view state by default and then enable it only for the controls that require it in the page.The ViewStateMode property takes an enumeration that has three values: Enabled, Disabled, and Inherit. Enabled enables view state for that control and for any child controls that are set to Inherit or that have nothing set. Disabled disables view state, and Inherit specifies that the control uses the ViewStateMode setting from the parent control. <asp:PlaceHolder ID="PlaceHolder1" runat="server" ViewStateMode="Disabled"> Disabled: <asp:Label ID="label1" runat="server" Text="[DeclaredValue]" /><br /> <asp:PlaceHolder ID="PlaceHolder2" runat="server" ViewStateMode="Enabled"> Enabled: <asp:Label ID="label2" runat="server" Text="[DeclaredValue]" /> </asp:PlaceHolder> </asp:PlaceHolder>

You can also find related Interview Question to
How do you implement ViewState for a control?
below:

Serialization is the process of converting an object into a stream of bytes. Deserialization is the opposite process of creating an object from a stream of bytes. Serialization/Deserialization is mostly used to transport objects (e.g. during remoting), or to persist objects (e.g. to a file or database).Serialization can be defined as the process of storing the state of an object to a storage medium. During this process, the public and private fields of the object and the name of the class, including the assembly containing the class, are converted to a stream of bytes, which is then written to a data stream. When the object is subsequently deserialized, an exact clone of the original object is created.Binary serialization preserves type fidelity, which is useful for preserving the state of an object between different invocations of an application. For example, you can share an object between different applications by serializing it to the clipboard. You can serialize an object to a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass objects "by value" from one computer or application domain to another. XML serialization serializes only public properties and fields and does not preserve type fidelity. This is useful when you want to provide or consume data without restricting the application that uses the data. Because XML is an open standard, it is an attractive choice for sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.

There are two separate mechanisms provided by the .NET class library - XmlSerializer and SoapFormatter/BinaryFormatter. Microsoft uses XmlSerializer for Web Services, and uses

SoapFormatter/BinaryFormatter for remoting. Both are available for use in your own code. (More...)

The heterogeneous linked list contains different data types in its nodes and we need a link, pointer to connect them. It is not possible to use ordinary pointers for this. So we go for void pointer. Void pointer is capable of storing pointer to any type as it is a generic pointer type. (More...)

An ASP.NET user control is a group of one or more server controls or static HTML elements that encapsulate a piece of functionality. A user control could simply be an extension of the functionality of an existing server control(s) (such as an image control that can be rotated or a calendar control that stores the date in a text box). Or, it could consist of several elements that work and interact together to get a job done (such as several controls grouped together that gather information about a user's previous work experience). (More...)

Web user controls : Web User Control is Easier to create and another thing is that its support is limited for users who use a visual design tool one gud thing is that its contains static layout one more thing a seprate copy is required for each application.

Web custom controls: Web Custom Control is typical to create and gud for dynamic layout and another thing is it have full tool support for user and a single copy of control is required because it is placed in Global Assembly cache. (More...)

View State persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes. (More...)

a).No server resources are required because state is in a structure in the page code.b).Simplicity.c).States are retained automatically.d).The values in view state are hashed, compressed, and encoded, thus representinge).A higher state of security than hidden fields.f).View state is good for caching data in Web frame configurations because thedata is cached on the client. (More...)

Find questions, FAQ's and their answers related to .NET, C#, Vb.Net, Sql Server and many more.

Now you can find lots of .NET, C#, Vb.Net, SQL Server,Windows, ASP.Net related Questions and their Answers here at www.dotnetspark.com. Our aim is to help you pass your certification Exams (MCP, MCSD, MCAD etc.,) with flying scores and get good name in your company.

So, Start looking our Interview Question section daily and improve your .NET Skills. You can also help others by posting Interview Questions and their Answers in this section.