I have overridden `OnError` method in the page:

```
public string script;

    protected override void OnError(EventArgs e)
    {
        script = "alert('error');";
    }

```

In the aspx, I have this:

```
<script type="text/javascript">
$(document).ready(function(){
        <%=script  %>;
    });
</script>

```

I am simulating an error in `Page_Load`, but its not firing the alert. If I switch the code from `OnError` to `OnLoad`, it works great.

Thoughts?