在OnChangeEventHandler中,我发现页面中的Respones对象没有了,也做不了跳转了,注册脚本也不行,请问怎么办?

解决方案 »

  1.   

    参考msdn
    AutomationFocusChangedEventHandler focusHandler = null;/// <summary>
    /// Create an event handler and register it.
    /// </summary>
    public void SubscribeToFocusChange()
    {
        focusHandler = new AutomationFocusChangedEventHandler(OnFocusChange);
        Automation.AddAutomationFocusChangedEventHandler(focusHandler);
    }/// <summary>
    /// Handle the event.
    /// </summary>
    /// <param name="src">Object that raised the event.</param>
    /// <param name="e">Event arguments.</param>
    private void OnFocusChange(object src, AutomationFocusChangedEventArgs e)
    {
        // TODO Add event handling code.
        // The arguments tell you which elements have lost and received focus.
    }/// <summary>
    /// Cancel subscription to the event.
    /// </summary>
    public void UnsubscribeFocusChange()
    {
        if (focusHandler != null)
        {
            Automation.RemoveAutomationFocusChangedEventHandler(focusHandler);
        }
    }
      

  2.   

    数据库的改变是随时可能发生的,这时候可能并没有人访问页面,那你要刷新哪个页面呢?如果你确定SqlDependency是在某次访问页面的过程中创建的(并且访问结束前就注销了OnChange事件),那可以用HttpContext.Current.Response来获取当前的页面输出。
    不过要小心HttpContext.Current可能是null,代表页面访问已经结束了(不可能老让浏览的用户等着)。
      

  3.   

    我想到了利用脚本去访问session,不知道这个性能怎么样
      

  4.   

    性能没问题,关键是session保存的数据不要太大