Atlas and error handling

Published Saturday, February 11, 2006 11:09 PM

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" >
            <ErrorTemplate>
                Woops!
                <br />
                Error is:
                <asp:Label ID="errorMessageLabel" runat="server" Text="Label"></asp:Label>
                <asp:Button ID="okButton" runat="server" Text="Clear Error" />
            </ErrorTemplate>
        </atlas:ScriptManager>

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">
      <click>
        <invokeMethod target="_PageRequestManager" method="clearError" />
      </click>
    </button>
    <label targetElement="errorMessageLabel">
      <bindings>
        <binding dataContext="_PageRequestManager" dataPath="pageErrorMessage" property="text" />
      </bindings>
    </label>

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.

by Glav

Comments

# Aldo Neyra said on Monday, March 6, 2006 3:51 PM

Can you Share your code, please???
I'm begining in Atlas, send me de complete code

Greetings from Peru

Sorry for my poor english

Leave a Comment

(required) 
(required) 
(optional)
(required) 

This Blog

Syndication