عرض مشاركة واحدة
عضو نشيط جدا
تاريخ التسجيل: Sep 2006-
#8 (permalink)  

تفضل

وهذا طلبك

Disabling Viewstate
Viewstate applies to many types of controls, not just the HTML form controls. For example if you set the text or content of a <span> or <div> element that contains the runat="server" attribute in your server-side code, this will be maintained across postbacks by default, using the viewstate. Likewise, the complete contents of a DataGrid control placed on a server-side <form> will be persisted.

However, there are often occasions where we don't actually need the viewstate to be persisted between postbacks. In these cases, the processing needed to generate it, decode it upon postback, and pass it twice across the network can be avoided by disabling it. For a complete page, including all the controls on it, we can add an instruction to the Page directive:

<%@Page Language="VB" EnableViewstate="False" %>

Some content is always stored in the hidden control named "__VIEWSTATE", even when iewstate is turned off for the page as a whole. This is the encoded representation of the ontrol hierarchy, which is used to ensure that the page is correctly posted to the same one as t was generated by, in order to give some protection against a user spoofing the server by ubmitting a different page.

If viewstate is disabled in the Page directive, it cannot be 'turned back on' for individual controls. However, e can leave viewstate enabled for the page as a whole, and then selectively disable it for individual controls o limit the viewstate size:

<span id="status" enableviewstate="false" runat="server" />

For 'status' elements, perhaps an <asp:Label>, <span> or <div> that you use to display interactive essages or feedback, be sure to add the enableviewstate="false" attribute so that the existing values re removed when the page is regenerated on the server each time.






__________________
Response.Write
(
م. خليل سليم

مطور مواقع ASP.NET

مطورو دوت نت

للتواصل : khalilme@hotmail.com

)
برمودا غير متواجد حالياً   قديم 19-09-2007, 02:52 AM
رد مع اقتباس