Wednesday, April 4, 2012

Applying a Form Template to Multiple Pages

Now that you have a custom form template in your application, you may want to apply this template to multiple pages. The Products page below uses the standard vertical list of fields.

Default layout of 'editForm1' on Products page of Code On Time generated web application

Start the web application generator, click on the project name, and press Design. In the Project Explorer, right-click on Categories / Products / container1, and press New Control.

New Control option in Code On Time Project Explorer

For the User Control property, choose “ProductsCustomTemplate”.

New Control with User Control of 'ProductsCustomTemplate' in Code On Time Project Designer

Press OK to save the page control. Press Browse button on the Designer tool bar. When the browser window comes up, navigate to Products page and select a product. You will see that the custom template is now being used to render the form.

Products page 'editForm1' using a custom form template

If you create a new product, you will see the createForm1 custom layout.

Products page 'createForm1' using a custom form template

Another place that we would like to use the custom template in is the Suppliers page. Navigate to this page in the web application, and select a supplier. You will see a list of products appear underneath the selected supplier. Click on the New Products button, and a modal window will open showing the default createForm1 layout.

 Default 'createForm1' in modal window on Suppliers page of web application created with Code On Time

Switch back to the web app generator, and right-click on Region / Suppliers / container1. Select New Control.

'New Control' option in Code On Time Explorer

In the User Control field, select “ProductsCustomTemplate”.

New Control with User Control of 'ProductsCustomTemplate' in Code On Time Designer

Press OK to save the control, and press Browse to regenerate the web application. Navigate to the Suppliers page, select a supplier, and press New Products again.

Custom Template in 'createForm1' in modal window on Suppliers page of web application created with Code On Time

If you edit a product linked to a supplier, you will see the following custom template:

Custom Template in 'editForm1' in modal window on Suppliers page of web application created with Code On Time

No comments:

You can find more about Code OnTime Generator, Data Aquarium Framework, and other great products here.


© 2010 Code OnTime LLC. Intelligent code generation software for ASP.NET. Visit us at http://codeontime.com