Page_Unload, session.clear(), session.abandon(), session.remove() and session.dispose()

Posted by Murugavelmsc under Interview Questions on 5/24/2013 | Points: 10 | Views : 3056 | Status : [Member] | Replies : 2
Hi Experts,

1. what is the use of Page_Unload and which scenario it can be used
2. difference between session.clear(), session.abandon(), session.remove() and session.dispose() explain in details
3. Include column in noclustered index?
4. difference between viewstate and hidden field which is faster why?
5. collation?


Thanks
Murugavel S

Regards,
Murugavel S
murugavel.sadagopan@gmail.com
http://murugavelmsc.blogspot.in/



Responses

Posted by: Satyapriyanayak on: 5/24/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
The View State is client state mechanism in the ASP.Net statement management.

The view state is control it will be used to maintain the state of the control across the posted back to the server. The value will be stored in the hidden control. Every time it needs to encryption and decryption (serialize and deserialize across the post backs).

The view state can be enabled by setting the property called EnableViewState="true/false". It can be set in the machine config/ web config/ page directives/ control level.

By default it is false. You can enable it by setting boolean flag.

This can be used with in the page and not across the page.

Viewstate["Version"] = txtVersionName.Text.ToString();

The view state also can store the data using the key and value combination. The data will be serialized and stored in the hidden control You can view the source code page and find the hidden control with _viewstate.


Drawbacks:
- Increase the page payload (when you have grid with many rows then every thing has to be loaded and retain again with serialize and deserilize)
- Additional overhead while serialize and deserialize.
- Increase the memory allocation on the server.





You can see the assigning and retrieval of view state in asp.net

protected void Button1_Click(object sender, System.EventArgs e)
{
ViewState["FavoriteColor"] = TextBox1.Text.ToString();
ViewState["City"] = TextBox2.Text.ToString();
Label1.Text = "Your data saved in ViewState.";
}
protected void Button2_Click(object sender, System.EventArgs e)
{
string color = (string)ViewState["FavoriteColor"];
string city = (string)ViewState["City"];

Label1.Text = "Hi your favorite color is: " + color +
"<br />and you came from: " + city;
}

If this post helps you mark it as answer
Thanks

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Annaharris on: 5/24/2013 [Member] Starter | Points: 25

Up
0
Down
Viewstate is much faster than hidden fields.

Murugavelmsc, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response