3
即使禁用視圖狀態和控制狀態,該值仍保留在asp.net webform頁面中。即使在對該頁面禁用Enableviewstate
爲false並通過將SavePageStateToPersistenceMedium()
替換爲空來禁用控件狀態之後,控件的值仍然保留在回發中。即使禁用視圖狀態和控制狀態,值仍保留在asp.net webform頁面中
/*value is still preserving in asp.net webform page
even if disable view state and control state*/
public class CustomTextBox : TextBox
{
public CustomTextBox()
{
}
//this method is ipostbackdatahandler's one
protected override void LoadControlState(object savedState)
{
//doing ntng here means we are not saving anything by this way
}
//this method is ipostbackdatahandler's one
protected override void RaisePostDataChangedEvent()
{
}
protected override void AddAttributesToRender(System.Web.UI.HtmlTextWriter writer)
{
//writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundColor, "Green");
writer.AddStyleAttribute(HtmlTextWriterStyle.Padding, "5px");
base.AddAttributesToRender(writer);
}
}
我該如何解決這種情況?
歡迎來到Stack Overflow。您可以通過按下問題下面的「編輯」按鈕來添加您的問題,而不是按評論按鈕。我已經爲你做了修復編輯,以便你現在更有可能得到答案,問題會更好。祝你好運。 –