Wednesday, April 26, 2006

Using Atlas on existing site

I have been playing with Atlas for ASP.NET April CTP for the last couple of days.

I quite like it so far, It is really easy to use if you are starting a new site, but not quite so easy if you are converting an existing site.

You have to do the following:

  • Install the Atlas CTP from Here

  • Open your existing solution and copy "Microsoft.Web.Atlas.dll" to the Bin directory of your solution.
    The default location for the dll is "C:\Program Files\Microsoft ASP.NET\Atlas\v2.0.50727\Atlas"

  • Add the following code to your web.config:

    Copy these elements as children of the <configuration> element:


      <configSections>
    <sectionGroup name="microsoft.web"
    type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup">
    <section name="converters"
    type="Microsoft.Web.Configuration.ConvertersSection"/>
    </sectionGroup>
    </configSections>

    <microsoft.web>
    <converters>
    <add
    type="Microsoft.Web.Script.Serialization.Converters.DataSetConverter"/>
    <add
    type="Microsoft.Web.Script.Serialization.Converters.DataRowConverter"/>
    <add
    type="Microsoft.Web.Script.Serialization.Converters.DataTableConverter"/>
    </converters>
    </microsoft.web>

    Copy (or integrate) these elements as children of the <system.web> element:


        <pages>
    <controls>
    <add namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>
    <add namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Atlas" tagPrefix="atlas"/>
    </controls>
    </pages>

    <!-- ASMX is mapped to a new handler so that proxy javascripts can also be served. -->
    <httpHandlers>
    <remove verb="*" path="*.asmx"/>
    <add verb="*" path="*.asmx" type="Microsoft.Web.Services.ScriptHandlerFactory" validate="false"/>
    </httpHandlers>
    <httpModules>
    <add name="ScriptModule" type="Microsoft.Web.Services.ScriptModule"/>
    </httpModules>


  • Start Programming!



In my case I just added an <atlas:UpdatePanel> around a couple of edit-inplace DataGrids.
Update Panels are quite good, they also allow updating based on triggers. For example you may want to update based on a selection on a DropDownList so you would:

<atlas:UpdatePanel runat="server" ID="Update1" mode="Conditional">
<ContentTemplate>
.....
</ContentTemplate>
<Triggers>
<atlas:ControlValueTrigger ControlID="DropDownList1" PropertyName="SelectedValue" />
</Triggers>
</atlas:UpdatePanel>




The only server control I would like (and I understand the security reasons) would be an atlas:FileUpload control.
As Scott Guthrie puts it "File-Uploads are a somewhat weird element in HTML -- since they are by-design non-scriptable (for security reasons, to avoid someone writing client-side script to maliciously upload a file from a browser).
As such, you'll need to be a little careful with how you use them with Atlas (or other Ajax frameworks)."

However, it would be cool if they had an atlas enabled FileUpload control, that you could tie in with an atlas:UpdateProgress control to give user feedback that the file is still updating. You can't do this at the moment, as the UpdateProgress fires before the FileUpload code, so any value in the FileUpload is cleared by a PostBack before you have a chance to do anything with it.

Any comments on how to get around this welcome!

1 comment:

Anonymous said...

Workst fine!
Thanks