WebForm里,有些脚本总希望每次刷新都执行,用了Atlas后, 总是要用ClientScript.RegisterStartupScript, 很烦.
终于找到个好办法.如下,每次刷新列表后, 为不同的条目设置对应颜色.
在页面任意处加入:
<script type="text/javascript">
///Init Color
function InitColor()
{
.
}
///Binding Event
Sys.Application.load.add(initialize);
function initialize()
{
_prm = Sys.WebForms.PageRequestManager;
_prm.propertyChanged.add(onPropertyChanged);
}
function onPropertyChanged(sender, args)
{
if(args.get_propertyName() == "inPostBack")
{
if(sender.get_inPostBack())//Post? [crabo grid]
{}
else//Back?
{
InitColor();
}
}
}
</script>
///Init Color
function InitColor()
{
.
}
///Binding Event
Sys.Application.load.add(initialize);
function initialize()
{
_prm = Sys.WebForms.PageRequestManager;
_prm.propertyChanged.add(onPropertyChanged);
}
function onPropertyChanged(sender, args)
{
if(args.get_propertyName() == "inPostBack")
{
if(sender.get_inPostBack())//Post? [crabo grid]
{}
else//Back?
{
InitColor();
}
}
}
</script>