(See full article in attachment in case of formatting issues).
Integrating Iron Speed Designer Pages into an Existing Master Page Application
In this article, I demonstrate how to add Iron Speed Designer generated pages to a sample Master Page-based ASP.NET application. ~ Jay Patel of JNovation, Inc
It is inexpensive to generate data management applications using Iron Speed Designer; however you are not limited to new applications alone. It is technically possible to add Iron Speed Designer generated pages to existing Master Page-based ASP.NET applications. In this article, I demonstrate how to add Iron Speed Designer generated pages to a sample Master Page-based ASP.NET application.
Various types of integration are possible depending on your project requirements. This article focuses on basic user interface and navigation integration. Security and other related topics are too specific and varied to cover in the scope of this article. Use of iFrames is also a possibility when integrating applications, but our goal is to run a precompiled Iron Speed Designer application in the same context as the ‘host’ ASP.NET application.
A final merged application is provided for your review. As in any integration scenario, it might be necessary to modify both applications to factor out code dependencies that prevent integration; where appropriate I’ve provided a reason for each change. Finally, the application we are integrating with in this example is a Web Application style application (one which has .csproj or .vbproj) and not a Web Site (as generated by Iron Speed Designer); see the Resources section for more detailed information on these two project styles. While it is technically possible to combine two Web Site projects, there may additional technical challenges that need to be considered.
Our overall goal is to add an Iron Speed Designer generated Reports table to an ASP.NET application. The general steps are as follows:
Step 1: Setup the ASP.NET sample ‘host’ application
Step 2: Create an Iron Speed Designer application for a single table
Step 3: Pre-compile the Iron Speed Designer application using a Web Deployment Project
Step 4: Add the Iron Speed Designer application to the host application
Step 5: Make necessary changes to both host and Iron Speed Designer applications along the way
Step 6: Ultimately, the Iron Speed Designer application will use the host’s Master Page creating a consistent look and feel
First, set up the sample Master Page-based ASP.NET application (SimpleWebSite). In this example, it is provided as a precompiled application and uses a Microsoft SQL Server 2005 database.
- Setup the application in IIS under virtual directory /ISArticle
- Restore the SimpleComponents database and setup user id/password as test / test123 or as desired
- Update the Web.Config ConnectionString section as needed. A number of different ConnectionStrings are used in the sample application. Simply search and replace these as needed.
- Verify the application is setup by navigating to http://localhost/ISArticle/Default.aspx and confirm it redirects to a login page. The user id and password are: test / p@ssw0rd
Creating an application
Create an Iron Speed Designer application for the Reports table using the standard Show Table, Add Record, Edit Record, and Show Record pages. The database contains a ‘Reports’ table for which no screens have been developed.
Step 1: Create a new application with the Application Wizard.
· Step 2: Select a page style in Iron Speed Designer. This example, I chose Sierra because it closely resembles our non Iron Speed Designer host application.
· Step 3: For Application Generation Options choose:
o New Page Options => Master Pages => PlaceHolderMain
o PlaceHolderMain was selected so the host application’s Master Page can be used, which uses this content place holder
· Step 4: Establish Database Server settings.
· Step 5: In the Pages screen, select the basic Show Table, Add Record, Edit Record, and Show Record pages along with the ‘Reports’ table from the SimpleComponents database.
· Step 6: In the Application Settings screen, select .NET Framework 3.5 so it’s the same as the host application.
Generate a standard Iron Speed Designer application using a built-in Master Page.
Next, is important to apply final changes to the Iron Speed Designer pages before deploying them to the host application. In Microsoft Visual Studio, search and replace ~/Shared/ with ../Shared so user controls can be found relative to the Iron Speed Designer page.
Then, navigate to Edit => Find and Replace => Replace in Files.
In this example we put all Iron Speed Designer pages in a ‘/IS’ subdirectory instead of at the root level of the ‘host’ site. This prevents clutter of additional folders and separates the Iron Speed Designer sub application from the host. I changed the location manually for the purposes of this article however you can automate the process in a production environment using a post-build MSBuild task (see Resources).
Now, incorporate SecurityApp into JobApplication by compiling SampleApp so it generates a single assembly (vs the random names generated by the Visual Studio ‘Publish Web Site’ option).
Create a Web Deployment Project from Visual Studio.
Right-Click on the Web Deployment Project in Solution Explorer and select Property Pages. Review the settings on the Compilateion and Output Assemblies section. Name the assembly SampleApp.
Finally, right-click on the Web Deployment Project node and select Build to compile and publish the application.
Once completed, you will see a new subdirectory where the *.wdproj is located that contains the generated application. Create an /IS folder at the root of the host application. Except for the Web.Config, copy all the generated files to the /IS folder of the host application.
During the testing of the application copy the Menu Panels, Header and Footer, and Master Pages directories into the root of the host application. You can remove these items once the merged application is ready.
Integrating the SampleApp’s ShowReportsTable.aspx user interface
- Step 1: Copy Iron Speed Designer applications assemblies from /IS/bin to the ‘host’ application’s /Bin directory.
- Step 2: Because Iron Speed Designer expects certain resources in specific locations, it’s important to copy them to the host site
- Copy SampleApp’s ‘Sierra’ theme (App_Themes/Sierra folder) to the host’s App_Themes folder
- Copy the Iron Speed Designer /Images folder to the root of the host site.
- Step 3: Apply IS Web.Config settings to host application
- Tag Mapping
- In our testing we came across an ‘Unknown server tag’ error, but were able to resolve it by updating the Register tag as shown (adding Assembly="SampleApp”). Apply same change to the remaining three reports pages; again; this could be further automated using a post-build step. The error is likely due to the page looking for an App_Code.dll file. Change from this
<%@ Register Tagprefix="SampleApp" Namespace="SampleApp.UI.Controls.ShowReportsTable" %>
<%@ Register Tagprefix="Selectors" Namespace="SampleApp" %>
<%@ Register Tagprefix="SampleApp" Namespace="SampleApp.UI.Controls.ShowReportsTable" Assembly="SampleApp" %>
<%@ Register Tagprefix="Selectors" Namespace="SampleApp" Assembly="SampleApp" %>
· Another challenge was references to App_Code when the table object gets created (error shown below). To resolve, search and replace in the entire solution this CreateQualifiedName("App_Code" with this CreateQualifiedName("SampleApp" . This could be done site wide using a pre-build step.
· To use the host applicaton’s Master Page we need to change the reference of the masterPageFile for the generated report pages.
· Open each of the .aspx pages in /Reports directory and replace culture="en-US" masterpagefile="~/Master Pages/HorizontalMenu.master" with culture="en-US" masterpagefile="~/Framework/MasterPages/SimpleWebSiteWithNavIS.Master" . This can be done as part of a post build step. If this were done in a ‘pre’-build step the application would not compile since it would not the new master page.
· Though the goal was to use the host application’s Master Page, we instead created a copy (SimpleWebSiteWithNavIS.Master) for the Iron Speed application and removed host application dependencies and added the necessary code that Iron Speed pages expect.
The final, merged application looks very similar to the non-Iron Speed ‘host’ application.
Styles from the host application’s theme were added to the standard Sierra page style in Iron Speed Designer (/App_Themes/Sierra/Styles.css) to make the screen even more consistent with the host application.
Finally, incorporate the Iron Speed Designer pages into the host’s menu. Simply copy the entire node from /IS/Menu Panels/Menu.SiteMap where title=”Reports” to an appropriate location the host’s Menu.SiteMap.
The steps above demonstrate how to integrate the user interface portion of Iron Speed Designer generated pages into our sample ASP.NET application. Additional steps may necessary to ensure the application generated with Iron Speed Designer works consistently on its own in addition to part of another application.
The steps described in the article vary based on the architecture of the application that Iron Speed Designer pages are being incorporated into, the environment in which the application is running, etc. The process outlined above may seem daunting at first however many of them can be accomplished using additional steps in the pre- and post-build process minimizing manual steps during deployment.
Iron Speed Designer generates new data-centric applications and adds value to existing ASP.NET applications.
- Web Application Project vs Web Site (link)
- Updating compiled application using post build task (link)
- Open Source MSBuild Tasks (link)
- Sample applications used in project (link coming soon).