1. Can the HTML controls retain state across postbacks?
No
2. Can the Asp.Net web server controls retain state across postbacks?
Yes, For all Asp.Net web server controls ViewState is enabled by default, to maintain the state between multiple roundtrips.
1. What is View State in Asp.net?
View state is nothing but a method that the ASP.NET use to preserve page and control values between postbacks. When the HTML markup for the page is rendered, the current state of the page and values that must be retained during postback are serialized into base64-encoded strings. This information is then put into the view state hidden field.
2. View state is client-side or server side state management technique?
View state is client-side state management technique
4. View state is used by Asp.net page atomatically or we need to apply it manuly?
View state is used automatically by the ASP.NET page framework to persist information that must be preserved between postbacks.
8. Difference between view state and a hidden field?
9. How do we ensure view state is not tampered?
Using the @Page directive and setting the EnableViewStateMac property to true.
10. Where is the ViewState information stored?
In the HTML hidden fields.(__ViewState)
When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. (Web page HTML)
How do you Enable/Disable a ViewState of Asp.Net server control on a page?
Every asp.net server control has a property called EnableViewState. We can set it to true/false.
By default it is set to true for every web server control
11. Disable ViewState property
ViewState can be disabled at the application, page, or control level.
To disable at the application level, put the following into your web.config file:
<Pages EnableViewState="false" ... />
To disable a particular page, you do it declaratively in the page directive:
<%@ Page EnableViewState=”false”
or programmatically in a page event:
private void Page_Init(object sender, System.EventArgs e)
{
this.EnableViewState = false;
}
Finally, to disable viewstate on a particular control, you can use the following:
<asp:datagrid EnableViewState="false" ... />
12. What is the lifespan for items stored in ViewState?
Items stored in the ViewState exist for the life of the current page.
This includes postbacks (to the same page).
No
2. Can the Asp.Net web server controls retain state across postbacks?
Yes, For all Asp.Net web server controls ViewState is enabled by default, to maintain the state between multiple roundtrips.
1. What is View State in Asp.net?
View state is nothing but a method that the ASP.NET use to preserve page and control values between postbacks. When the HTML markup for the page is rendered, the current state of the page and values that must be retained during postback are serialized into base64-encoded strings. This information is then put into the view state hidden field.
2. View state is client-side or server side state management technique?
View state is client-side state management technique
3. What are the client-side state management techenique supported by ASP.NET?
- View state
- Control state
- Hidden fields
- Cookies
- Query strings
4. View state is used by Asp.net page atomatically or we need to apply it manuly?
View state is used automatically by the ASP.NET page framework to persist information that must be preserved between postbacks.
5. When you can use(take advantage of vs) view state?
or What you can do by use view state?
- Keep values between postbacks without storing them in session state or in a user profile.
- Store the values of page or control properties that you define.
- Create a custom view state provider that lets you store view state information in a SQL Server database or in another data store.
6. What are the advantages of using view state?
- No server resources are required : The view state is contained in a structure within the page code.
- Simple implementation : View state does not require any custom programming to use. It is on by default to maintain state data on controls.
- Enhanced security features : The values in view state are hashed, compressed, and encoded for Unicode implementations, which provides more security than using hidden fields.
7. What are the limitations of view state?
Limitations:
- Because view state is stored in the page, it results in a larger total page size.
- ASP.NET uses view state only with page and control properties.
- View state isn't a good place to store sensitive information that the client shouldn't be allowed to see.
8. Difference between view state and a hidden field?
- Hidden Fields does not support for storing structured values while View State support for structured values.
- Hidden field stores a single variable in its value property and must be explicitly added it to the page
- View State stores complex structure and Each control on a Web Forms page, including the page itself, has a ViewState property,
9. How do we ensure view state is not tampered?
Using the @Page directive and setting the EnableViewStateMac property to true.
10. Where is the ViewState information stored?
In the HTML hidden fields.(__ViewState)
When the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field. (Web page HTML)
How do you Enable/Disable a ViewState of Asp.Net server control on a page?
Every asp.net server control has a property called EnableViewState. We can set it to true/false.
By default it is set to true for every web server control
11. Disable ViewState property
ViewState can be disabled at the application, page, or control level.
To disable at the application level, put the following into your web.config file:
<Pages EnableViewState="false" ... />
To disable a particular page, you do it declaratively in the page directive:
<%@ Page EnableViewState=”false”
or programmatically in a page event:
private void Page_Init(object sender, System.EventArgs e)
{
this.EnableViewState = false;
}
Finally, to disable viewstate on a particular control, you can use the following:
<asp:datagrid EnableViewState="false" ... />
12. What is the lifespan for items stored in ViewState?
Items stored in the ViewState exist for the life of the current page.
This includes postbacks (to the same page).
No comments:
Post a Comment