我在Asp.Net一個網頁,我附上了一個名爲btnRecordHours_Click
在按鈕上單擊Aspx頁面時獲取視圖狀態錯誤?
protected void btnRecordHours_Click(object sender, EventArgs e)
{
//Some Code
}
方法就可以在其OnClick
事件按鈕
<asp:Button ID="btnRecordHours" runat="server" Text="<%$ Resources:VolunteerDashboard,btnRecordHours%>"
CssClass="buttonGreen buttonWidth" OnClick="btnRecordHours_Click" />
有了這個可是當我點擊這個按鈕我得到以下錯誤:
Failed to load viewstate.
The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request. For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.
它不是能夠在發回Click
事件時直接顯示此錯誤OnClick
。
Hyperlink
和其他一些按鈕在這個頁面上正常工作,但這個問題仍然存在一些按鈕。
你是否在頁面頁面或者頁面頁面動態添加了任何控件? – 2012-02-21 17:21:04
不,我們不是動態地在Page_Load或Page_PreRender中添加控件 – 2012-02-21 17:28:23
您是否使用jQuery來更改表單上的任何(甚至是隱藏的字段)值? – 2012-02-21 18:00:41