Click here to Skip to main content
Click here to Skip to main content

Creating AJAX-enabled Mash-ups with C1UpdateSplitter

, 14 Dec 2006
This article describes a sample "mash-up" application that combines data from three different Web services and displays the results using a variety of ComponentOne ASP.NET controls, including C1UpdateSplitter, which extends the functionality of the "Atlas" UpdatePanel.

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

This is a showcase review for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

This article describes a sample "mash-up" application that combines data from three different Web services and displays the results using a variety of ComponentOne ASP.NET controls, including C1UpdateSplitter, which extends the functionality of the "Atlas" UpdatePanel by adding dual content panels separated by a resizable splitter bar.

Terminology

Asynchronous JavaScript and XML (AJAX) is a development technique for creating rich, interactive Web applications that feel more like desktop applications, where users are accustomed to immediate responses. In a conventional Web application, user input is sent to the server, which then acts upon the data and responds by sending back an updated Web page in its entirety, a process known as a postback. In an AJAX-enabled application, small amounts of data are exchanged with the server behind the scenes, so that only the affected portions of the page need to be refreshed. To the user, the page seems faster and more responsive.

Microsoft ASP.NET AJAX (formerly code-named "Atlas") is an extension of ASP.NET 2.0 that provides a framework for creating efficient, highly-interactive Web applications that work across the most popular browsers. In particular, the UpdatePanel server control identifies a page region as updatable using partial-page rendering. For more information, including the latest downloads, visit the Microsoft ASP.NET AJAX site.

The term "mash-up" is used to describe Web applications that combine content from multiple sources such as RSS feeds, Web services, or other public interfaces. The sample application depicted in the following illustration uses three distinct Web services, each of which returns different information based on a zip code:

  • City and state
  • Weather forecasts
  • Movie theaters and show times

To the end user, all of the data appears to come from a single source, even though there are three separate data sources "mashed-up" into one application.

About ComponentOne Studio Enterprise

ComponentOne Studio Enterprise is a comprehensive suite of components for developing Windows, Web, and mobile applications. For ASP.NET development, Studio Enterprise includes dozens of controls including a grid, 2D and 3D charts, a report designer/viewer, user interface and input elements, and components for generating popular file formats such as Adobe PDF, Microsoft Excel, and ZIP compression.

The 2006 v2 release of Studio Enterprise introduced support for AJAX in conventional ASP.NET 2.0 (that is, without the "Atlas" extensions). For example, the C1WebGrid control added a CallbackOptions property for specifying which operations should use the AJAX mechanism. For details about the AJAX implementation in specific components, please see this article.

The 2006 v3 release of Studio Enterprise introduced compatibility for the "Atlas" extensions. This means that any ComponentOne ASP.NET component can safely reside within an "Atlas" UpdatePanel and participate in partial-page rendering without any special coding or property settings.

This release also introduced a new product, ComponentOne WebSplitter for ASP.NET, that implements two container controls with resizable panels, similar to the Windows Forms SplitContainer control:

  • C1WebSplitter, for conventional ASP.NET 2.0
  • C1UpdateSplitter, for ASP.NET AJAX ("Atlas")

C1WebSplitter and C1UpdateSplitter are functionally equivalent. The only difference is that the C1UpdateSplitter control creates and manages an "Atlas" UpdatePanel behind the scenes.

Running the Sample Application

To view the mash-up sample in action, click here.

Enter a zip code into the text box, then click the green circle with the arrow. You should see the following changes:

  • The label below the text box now displays the corresponding city and state.
  • The Weather box displays today's forecast.
  • The topmost grid displays a list of nearby movie theaters.

Now, try interacting with the form as follows:

  • Select the Weekly Forecast radio button. Notice that additional weather data and a vertical scroll bar appear, but the grids do not flicker.
  • Select a row in the Theater grid. Notice that the other rows do not repaint. The Movie grid is updated based on the selected row.
  • Click the dotted image in the vertical splitter bar to collapse the left panel. Click it again to restore the left panel.
  • Click the dotted image in the horizontal splitter bar to collapse the top panel. Click it again to restore the top panel.
  • Grab either splitter bar outside of its dotted image (you should see a double-arrow cursor instead of a finger), then drag it to a different position. The panels resize accordingly, and their scroll bars are shown or removed as needed to accommodate the inner contents.

Designing the Form

The main visual element of the mash-up application is a C1UpdateSplitter control with vertical orientation. The left panel contains a C1WebTopicBar control, which provides collapsible groups that act as containers for arbitrary content. The right panel contains another C1UpdateSplitter control, this time with horizontal orientation. The top and bottom panels of this inner splitter each contain a C1WebGrid control. The two grids form a master-detail relationship between theaters and movies. The following figure depicts the hierarchy of controls on the form:

The form also contains three non-visual components: a ScriptManager with its PartialRendering property set to True, an ObjectDataSource for binding the master grid to the list of movie theaters, and an UpdateProgress component for displaying animated feedback during partial-page rendering, as shown here.

At design time, C1UpdateSplitter allows you to drag arbitrary components onto either one of its panels. The following figure shows a splitter in its default vertical orientation, with a C1WebTopicBar component added to its left panel.

You can also nest C1UpdateSplitter controls on the design surface. In the next figure, a second C1UpdateSplitter has been added to the right panel of the first splitter. The orientation of the inner splitter was changed to horizontal, and a C1WebGrid component was added to each inner panel.

These five components form the overall structure of the mash-up page. For the outermost (vertical) splitter, C1UpdateSplitter1, the following properties were set:

AutoResize True
BorderColor White
Height 500px
SplitterDistance 256
Width 800px

The SplitterDistance value denotes the initial position of the splitter bar, in pixels. In addition, the following sub-object properties were set for C1UpdateSplitter1:

Bar.CollapsedCssClass SplitterCollapsedVertical
Bar.CollapseHoverImageUrl ~/splitter_colhover_vert.gif
Bar.CollapseImageUrl ~/splitter_col_vert.gif
Bar.CssClass Splitter
Bar.DragCssClass SplitterDrag
Bar.ExpandHoverImageUrl ~/splitter_exphover_vert.gif
Bar.ExpandImageUrl ~/splitter_exp_vert.gif
Bar.HoverCssClass SplitterHover
Panel1.BackColor 122, 160, 230
Panel2.ScrollBars None

Note that scroll bars are disabled for the second panel, since scrolling will be handled by the nested horizontal splitter. The CssClass properties reference named styles defined in an inline style sheet in Default.aspx. These styles are used to control the background colors and borders for the splitter bars.

For the innermost (horizontal) splitter, C1UpdateSplitter2, the following properties were set:

AutoResize True
BorderColor #7AA0E6
BorderStyle Solid
BorderWidth 1px
Height 100%
Orientation Horizontal
SplitterDistance 240
Width 100%

Note that the dimensions are specified as 100% instead of absolute units. In addition, the following sub-object properties were set for C1UpdateSplitter2:

Bar.CollapsedCssClass SplitterCollapsedHorizontal
Bar.CollapseHoverImageUrl ~/splitter_colhover_horz.gif
Bar.CollapseImageUrl ~/splitter_col_horz.gif
Bar.CssClass Splitter
Bar.DragCssClass SplitterDrag
Bar.ExpandHoverImageUrl ~/splitter_exphover_horz.gif
Bar.ExpandImageUrl ~/splitter_exp_horz.gif
Bar.HoverCssClass SplitterHover

Conclusion

When using C1UpdateSplitter, you do not need to write additional code to update the constituent controls within the splitter panels. The mash-up sample handles server-side events for button clicks and grid row selections as if it were a conventional ASP.NET application without AJAX extensions. However, with AJAX, the application is far more fluid and responsive, especially with the added value of the C1UpdateSplitter control.

If you would like to learn more about how the mash-up sample consumes Web services, please see this article, which also contains a link for downloading the source code.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

John C. Juback

United States United States
John Juback has been developing software components since the early days of Visual Basic. A graduate of Carnegie Mellon University, he was one of the original developers of APEX Software's flagship control, True DBGrid. As Senior Technology Evangelist for ComponentOne, John develops .NET and ASP.NET applications, writes technical articles, represents ComponentOne at industry events, and devises novel uses for C1 components.

Comments and Discussions

 
QuestionHow to update a WebGrid in a panel without Refresh? PinmemberLatifa51911-Feb-07 10:22 
AnswerRe: How to update a WebGrid in a panel without Refresh? PinmemberJohn C. Juback15-Feb-07 10:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140827.1 | Last Updated 14 Dec 2006
Article Copyright 2006 by John C. Juback
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid