Atlas and error handling

Was playing around with the January CTP of Atlas which was recently released and found the error handling within Atlas interesting.

As you may already know, you must place an <atlas:ScriptManager> control within your Atlas enabled page. To handle an error situation, you can add an error template to the script manager control as shown in the following example:

        <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" >
                <br />
                Error is:
                <asp:Label ID="errorMessageLabel" runat="server" Text="Label"></asp:Label>
                <asp:Button ID="okButton" runat="server" Text="Clear Error" />

Now, when an exception is generated on the server through one of the async methods, the error template you have defined will display. You'll notice a label and button with an id of 'errorMessageLabel' and 'okButton' respectively. These id names are specific names and Atlas will hook up special behaviour to these controls. For the 'errorMessageLabel' control, the text of the exception will be placed here for you. For the 'okButton', clicking this will cause the error/exception display to be cleared from your browser screen.

The id names are effectively special names that Atlas recognises and attributes special behaviour to. You can see this in the generated page output. Doing a view source on a page that contains the ScriptManager control above yields the following XML script:

    <button targetElement="okButton">
        <invokeMethod target="_PageRequestManager" method="clearError" />
    <label targetElement="errorMessageLabel">
        <binding dataContext="_PageRequestManager" dataPath="pageErrorMessage" property="text" />

Here you can see the 'okButton' calling the 'clearError ' method of the _PageRequestManager object, and also binding the 'errorMessageLabel' control to the 'pageErrorMessage' property of the _PageRequestManager object.

Now I dont know if this is new to the January CTP or not, but I thought it was interesting none the less.

1 Comment

Comments have been disabled for this content.