OpenAccessDataSource_Updated and RadWindowManager.RadAlert

Thread is closed for posting
2 posts, 0 answers
  1. Eric Krauska
    Eric Krauska avatar
    26 posts
    Member since:
    Dec 2007

    Posted 22 Sep 2011 Link to this post

    Not sure which forum to post this is in since I am using OpenAccessDataSource and a RadWindowManager. 
    When the Updated event is called on the OpenAccessDataSource, I am checking for an exception and am trying to use the WindowManager to give feedback to the user.  It seems that if the DB returns an exception that the windowmanager won't display the exception.  To test, use the below code.  In the DB, I have a GUID column and whatever else.  While in edit mode, if I attempt to remove some characters from the Guid and click Update an exception is thrown and I get the display from windowmanager.  This is because the source is mscorlib PRIOR to the DB update being called.  Now, if I change something else that will cause the DB to generate an exception (i.e. pass 10 characters in to a column that is nvarchar(2)).  The Update event is still thrown, the exception is caught, but the windowmanager never displays the informaiton.  It seems like the page is attempting to be redrawn after a DB error so the RadAlert is never displayed.

    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server"></telerik:RadScriptManager>   
    <telerik:RadWindowManager ID="_windowManager" DestroyOnClose="true" Opacity="100" runat="server" AutoSizeBehaviors="Default" EnableShadow="true" Modal="true" Skin="Forest"></telerik:RadWindowManager>
                                     
    <telerik:RadGrid ID="_timeFailures" runat="server"
        DataSourceID="_employeeTimeEntries" AllowAutomaticInserts="True" AllowAutomaticUpdates="True"
        GridLines="None" Skin="Forest" AutoGenerateEditColumn="True"
        AllowPaging="True" AutoGenerateDeleteColumn="True" CellSpacing="0" >
        <MasterTableView DataKeyNames="TimeLogID"></MasterTableView>
    </telerik:RadGrid>
    <telerik:OpenAccessDataSource ID="_employeeTimeEntries" runat="server"
        ObjectContextProvider="Keeley.Barcode.DAL.KeeleyBarcodeDataContext, Keeley.Barcode.DAL"
        TypeName="Keeley.Barcode.DAL.TimeLog"
         onupdated="_timeFailuresDataSource_Updated" >
    </telerik:OpenAccessDataSource>
    </form>

    And the code behind:
    protected void _timeFailuresDataSource_Updated(object sender, Telerik.OpenAccess.OpenAccessDataSourceChangedEventArgs e)
    {
        if (e.Exception != null)
        {
            _windowManager.RadAlert(e.Exception.Message, null, null, "Error", null);
            e.ExceptionHandled = true;
        }
    }

  2. Marin Bratanov
    Admin
    Marin Bratanov avatar
    5359 posts

    Posted 26 Sep 2011 Link to this post

    Hi Eric,

    I tested this behavior on the OpenAccessDatasource demo from the OpenAccess SDK and things seem to be working correctly. The only case when I am able to break the RadAlert is when I pass an invalid string to it, which would result in a JavaScript error.

    The RadAlert (and RadConfirm, and RadPrompt, for that matter) take an HTML string for the message. This means that the special symbols for the programming language you are using to set this string need to be escaped by the developer, as they are the programming language's limitation in working with strings - this is the reason why characters such as single quotes ('), double quotes("), backslashes, etc need to be escaped manually.

    For example in HTML the symbol for new line is <br /> and not  \n or \r or CR or LF (as is in VB) and this also needs to be taken into consideration - the programming environment is different than the HTML environment and thus such specialized symbols/commands will naturally differ. We cannot foresee all the possible combinations that might be used and thus we do not transform the string the developer passes. You could use a simple replace function to change the CS new lines into HTML new lines and also for escaping quotation marks, which are the most likely reason for such an issue.

    You can find a video from my experiment here: http://screencast.com/t/eKwllSANwBA. As you can see only invalid strings resulted in the erroneous behavior.


    All the best,
    Marin
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top