1

有没有办法知道事件的最后一个视图索引是ActiveViewChanged什么?

protected void mltv_ActiveViewChanged(object sender, EventArgs e)
    {
       //Here i nedd to know what it was, because here it is already changed  
    }
4

2 回答 2

0

检查财产mltv.ActiveViewIndex。到了这里

于 2013-03-09T11:52:29.670 回答
0

只需将 Load Event 用于用户控制并引用 ActiveViewIndex。它应该在更改之前具有 ActiveViewIndex。对于下面的示例,我只是使用上下文项作为支持,但如果您有一个可以使用的类级别变量:

protected void mltv_Load(object sender, EventArgs e)
{
   //Add your property backing or class variable here
   int pos = mltv.ActiveViewIndex;
   if (pos == -1)
       return;
   Context.Items["mltv_ActiveViewIndexOnLoad"] = pos;

}
protected void mltv_ActiveViewChanged(object sender, EventArgs e)
{
   //Retrieve property, private variable, here:
   var lastViewIndex = -1; 
   if (Context.Items["mltv_ActiveViewIndexOnLoad"] != null)
   {
       lastViewIndex = (int)(Context.Items["mltv_ActiveViewIndexOnLoad"]);
   }

}
于 2018-05-17T14:07:51.750 回答