【发布时间】:2015-08-16 03:13:48
【问题描述】:
即使我禁用了视图状态和控件状态,该值仍然保留在 asp.net 网页表单页面中。即使在我为该页面禁用 Enableviewstate 为 false 并通过将 SavePageStateToPersistenceMedium() 覆盖为空来禁用控件状态后,控件的值仍保留在回发中。
/*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。您可以通过按问题下方的“
edit”按钮而不是按评论按钮来添加您的问题。我已经为您完成了修复编辑,以便您现在问题更好地得到答案。祝你好运。