如何知道ActiveViewChanged事件上MultiView的最后一个视图索引?

时间:2013-03-09 11:43:37

标签: c# asp.net

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

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

2 个答案:

答案 0 :(得分:0)

检查属性mltv.ActiveViewIndex。得到here

答案 1 :(得分: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"]);
   }

}