zoukankan
html css js c++ java
实现 IStateManager 接口的服务器控件在设定属性时的注意点
设定属性后,要添加一句
ViewState.SetItemDirty() 的调用,这样在后续的阶段,StateBag.SaveViewState() 方法被调用时,才会保存该属性的值。
例子如下:
public
virtual
ImageAlign RightImageAlign
{
get
{
object
o
=
ViewState[
"
ItemRightImageAlign
"
];
if
(o
==
null
)
return
ImageAlign.NotSet;
else
return
(ImageAlign) o;
}
set
{
ViewState[
"
ItemRightImageAlign
"
]
=
value;
ViewState.SetItemDirty(
"
ItemRightImageAlign
"
,
true
);
}
}
通过 Reflector 看到 System.Web.UI.StateBag 类的
SaveViewState() 方法的代码如下,可以验证这一点:
internal
object
SaveViewState()
{
ArrayList list1
=
null
;
ArrayList list2
=
null
;
if
(
this
.bag.Count
!=
0
)
{
IDictionaryEnumerator enumerator1
=
this
.bag.GetEnumerator();
while
(enumerator1.MoveNext())
{
StateItem item1
=
(StateItem) enumerator1.Value;
if
(item1.IsDirty)
{
if
(list1
==
null
)
{
list1
=
new
ArrayList(
5
);
list2
=
new
ArrayList(
5
);
}
list1.Add(enumerator1.Key);
list2.Add(item1.Value);
}
}
if
(list1
!=
null
)
{
return
new
Pair(list1, list2);
}
}
return
null
;
}
查看全文
相关阅读:
ACM2114_S[I](1^3+2^3+3^3)
幻源境第二十八章
Java中间件之RMI及实例介绍 · zijian's blog
玩转iOS开发:iOS中的GCD开发(三)
浅谈在ES5环境下实现const
concurrent包分析之Executor框架
Inheritance Learning Note
开发岗笔试基础题总结
论文笔记[Slalom: Fast, Verifiable and Private Execution of Neural Networks in Trusted Hardware]
logstash收集nginx日志
原文地址:https://www.cnblogs.com/RChen/p/204525.html
最新文章
【codeforces 742C】Arpa's loud Owf and Mehrdad's evil plan
【9931】火车票
【b802】火柴棒等式
【25.64%】【codeforces 570E】Pig and Palindromes
【30.49%】【codeforces 569A】Music
【40.17%】【codeforces 569B】Inventory
【34.88%】【codeforces 569C】Primes or Palindromes?
【63.73%】【codeforces 560A】Currency System in Geraldion
Android编程中的5种数据存储方式
Disk array controller and information processing apparatus
热门文章
SQL Server索引怎么用
有哪些新手程序员不知道的小技巧?
有哪些新手程序员不知道的小技巧?
有哪些新手程序员不知道的小技巧?
数据库的那些事(全是干货)
数据库的那些事(全是干货)
数据库的那些事(全是干货)
MongoDB常用语句
MongoDB常用语句
MongoDB常用语句
Copyright © 2011-2022 走看看