Today I finally took some time to work with AJAX and LLBLGen. It was amazingly simple using the ComponentArt Callback control.
The purpose of the exercise was to see how easy it was to implement AJAX techniques with LLBLGen as the data source. In my sample, I click a hypelink and get some data without the postback.
In my implementation, I created a web service that fetched all employees from northwind into a typed list and returned a typed list from a web service as a data set. I created a simple web form with a data grid and a CA Callback control. Then I wrote the client side javascript and code behind callback method.
The code behind callback was very simple, it simply invokes a web method, sets data source of the data grid to the result of the web method, and renders the output of the data grid to the CA Callback control.
Implementing AJAX using ATLAS appears to be much more hassle than its worth especially considering I was up and running with the CA Callback control in < 20 minutes. Like typical Microsoft Sanctioned projects, there is little documentation for implementing ATLAS outside of the standard "Hello World" implementation, and besides that the declarative model seems very counter intuitive.
I have included the highlights of the code below. One thing to note is that I did not need to get the data from a web service, I just chose to use a web service because I already had one lying around that I could use. Because the CA Callback allows you to get into the code behind you can go directly to a LLBLGen library and get the EntityCollection, Entity, TypedList, TypedView, or whatever else you might want to do.
I did the sample in VS.NET 2005 if anyone wants to see the source, let me know.
The Client Side javascript looks like this:
<script type="text/javascript">
function renderControl(param)
{
Callback1.Callback(param);
}
</script>
The code behind callback method looks like this:
protected void Callback1_Callback(object sender, ComponentArt.Web.UI.CallBackEventArgs e)
{
FADV.Services.Northwind.NorthwindServices svc = new FADV.Services.Northwind.NorthwindServices();
DataTable table = svc.GetAllEmployees().Tables[0];
DataGrid1.Visible = true;
DataGrid1.DataSource = table;
DataGrid1.DataBind();
DataGrid1.RenderControl(e.Output);
}
The client html in the asp.net page looks like this:
<form id="form1" runat="server">
<div>
<a href="javascript:renderControl('');">Get Employees</a>
<br />
<ComponentArt:CallBack ID="Callback1" runat="server" Height="250" OnCallback="Callback1_Callback"
Width="350">
<Content>
</Content>
</ComponentArt:CallBack>
<asp:DataGrid ID="DataGrid1" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
Style="border-right: #666666 1px solid; border-top: #666666 1px solid; border-left: #666666 1px solid;
border-bottom: #666666 1px solid" Visible="False">
</asp:DataGrid>
</div>
</form>