ViewStateMode與EnableViewState的差別)

來源:互聯網
上載者:User

  ASP.NET4.0起,各種Control(包含Page)都新增了一個屬性,稱為ViewStateMode,這個屬性的說明:Specifies whether view state will be enabled for a control。 代表它是用在控制每個Control的ViewState的啟用與關閉狀態,而這個屬性有三種值可以設定,分別是以下三種:

(參考自:http://msdn.microsoft.com/zh-tw/magazine/ee431529.aspx)

  但問題來了,根據這樣的說明,兩者之間似乎沒有太大差別,那為何還要有這個屬性,總不會是多餘的吧,自然不是的,我們看看下方這篇文章:
ViewStateMode Enumeration

  往下看到Remark的部分,這裡有一段話:

  The ViewStateMode property of a page or a control has an effect only if the EnableViewState property is set to true. If the EnableViewState property is set to false, view state will be turned off even if the ViewStateMode property is set to Enabled.

  ViewStateMode 只有在EnableViewState的屬性設定為True時才會有作用,從這邊我們可以打個比方來說,EnableViewState算是電源的總開 關,ViewStateMode則算是每間房間的電燈開關,只要總開關關閉了,其他的開關如何切換都沒有效果了。

 

轉自:http://www.dotblogs.com.tw/jimmyyu/archive/2010/03/14/viewstatemode-vs-enableviewstate.aspx

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.