What are the advantages and disadvantages of viewstate ?



What are the advantages and disadvantages of viewstate ?..

Answer / surendra singh

The primary advantages of the ViewState feature in ASP.NET are:
1. Simplicity. There is no need to write possibly complex code to store form data between page submissions.
2. Flexibility. It is possible to enable, configure, and disable ViewState on a control-by-control basis, choosing to persist the values of some fields but not others.
There are, however a few disadvantages that are worth pointing out:
1. Does not track across pages. ViewState information does not automatically transfer from page to page. With the session
approach, values can be stored in the session and accessed from other pages. This is not possible with ViewState, so storing
data into the session must be done explicitly.
2. ViewState is not suitable for transferring data for back-end systems. That is, data still has to be transferred to the back
end using some form of data object.
Describe session handling in a webfarm, how does it work and what are the limits ?
ASP.NET Session supports storing of session data in 3 ways, i] in In-Process ( in the same memory that ASP.NET uses) , ii] out-of-process using Windows NT Service )in separate memory from ASP.NET ) or iii] in SQL Server (persistent storage). Both the Windows Service and SQL Server solution support a webfarm scenario where all the web-servers can be configured to share common session state store.

1. Windows Service :
We can start this service by Start | Control Panel | Administrative Tools | Services |. In that we service names ASP.NET State Service. We can start or stop service by manually or configure to start automatically. Then we have to configure our web.config file

<CONFIGURATION><configuration>
<system.web>
<SessionState
mode = “StateServer”
stateConnectionString = “tcpip=127.0.0.1:42424”
stateNetworkTimeout = “10”
sqlConnectionString=”data source = 127.0.0.1; uid=sa;pwd=”
cookieless =”Flase”
timeout= “20” />
</system.web>
</configuration> </SYSTEM.WEB>
</CONFIGURATION>
Here ASP.Net Session is directed to use Windows Service for state management on local server (address : 127.0.0.1 is TCP/IP loop-back address). The default port is 42424. we can configure to any port but for that we have to manually edit the registry.
Follow these simple steps
- In a webfarm make sure you have the same config file in all your web servers.
- Also make sure your objects are serializable.
- For session state to be maintained across different web servers in the webfarm, the application path of the web-site in the IIS Metabase should be identical in all the web-servers in the webfarm.
Which template must you provide, in order to display data in a Repeater control ?
You have to use the ItemTemplate to Display data. Syntax is as follows,
< ItemTemplate >
< div class =”rItem” >
< img src=”images/<%# Container.DataItem(“ImageURL”)%>” hspace=”10” />
< b > <% # Container.DataItem(“Title”)%>
< /div >
< ItemTemplate >

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

what is NET Framework ?

4 Answers   TCS,


What is distributed system in asp.net?

0 Answers  


difference between Trace and Debug ?

9 Answers   Accenture, Addlux, Microsoft,


Why does my asp.net file have multiple tag with runat=server?

0 Answers  


Given an ASP.NET Web Form called WebFrom1, what class does the WebForm1 class inherit from by default? a) System.Web.Form b) System.Web.GUI.Page c) System.Web.UI.Page d) System.Web.UI.Form

3 Answers   Syntax Softtech,






I M working in 1.1 .net framework. In a page I have 5 text box & 2 data grid. In PageLoad() All text box will populate with blank value & 1st dataGrid with some value. When I click on EDIT button Of the 1st dataGrid,The Relevent data Of the particular row will populate in first 3 textboxs & corresponding relevent data Will populate in the 2nd DataGrid. Now when I click 2nd datagrid's EDIT button of a perticular Row,relevent data will populate on last 2 textboxs & 1st 3 textbox's value will be same as per as it was........ ........My Problem Is ........... When I click on edit button Of 2nd DataGrid, 1st 3 text boxes values goes Off & 2nd DataGrid Is goes off Due to Postback.but The relevent value is populated In last 2 textboxes.So How I stoped this postback??So that all the data in 1st 3 textboxes will be same.So that I can edit the values of 2nd Grid with 1st 3 textBoxes value.. plz dirctly mail me 1 copy of post to... maloy.adhikari@in.com

2 Answers  


Explain how do you validate the controls in an asp .net page?

0 Answers  


we are working in .net namespaces like using system.io,system.text. these namespace before we use "using " keyword what means of using?

7 Answers   CEI, CSC, HCL, Tech Mahindra,


What is difference between or and orelse?

0 Answers  


Which asp.net objects encapsulate the state of the client and the browser?

0 Answers  


What are the main advantages of using asp.net?

0 Answers  


How can we call webservices in Banking Applications? and where we are using it?

0 Answers   FCG,


Categories