Forums: How to get back non-table based pages - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to get back non-table based pages

#1 User is offline   Pete K 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 231
  • Joined: 05-February 16

Posted 07 June 2016 - 07:13 PM

In Iron Speed, you could create ad-hoc pages that could include the site header, footer, menu, etc. and that maintained the same theme as the rest of your app. This is handy for help pages, informational, and other pages that are not based directly on your data tables. ASPR.net does not have that functionality. Sure, you can create static html pages, but they have two drawbacks (at least). First of all, in order to get the same look and feel of your site, you would have to hard-code all of that into each page you create and then replicate any changes you might make to the site theme later. Second, the page is static so you won't be able to display dynamic information. But there is an easy solution. Create a quick and dirty content management system, right inside your app!

What I do is create a table called Pages with at minimum id (could be varchar or int), title (varchar), and bodyText (ntext displayed as HTML) fields. I also include a field I call "DynamicText" which I leave blank in the db. Then I set up my view page so it looks all nice, removing the field labels, moving the page title to the header, etc. I also place my DynamicText field under the bodyText field. You can link to a page from anywhere in your app: a button, the menu, even create a custom menu page for just this content by modding a list page to display the titles vertically and linking them up.

About that DynamicText field. There are many ways you might use it. For one of my apps, I had to create my own log-in system and I wanted to display a user-friendly page on failed attempts. I set the bodyText field to a very general "your login failed -- here's who to contact for more info, etc" and then at run time, I was able to provide more specific info in a session variable (User name not found, user marked as inactive, no user group assigned, etc.) and then display that session variable in the DynamicText field.

Now here's the really cool part about all of this: Since everything is in the database, you don't need to touch your source in order to make updates to any of these pages. Better still, you can empower your admin user(s) to maintain them on their own. No need to call the developer to update some text!

Hat tip to fellow ISD and ASPR.net veteran Jerry (jadach) for this idea.


----------------------------------------------------------
Pete K.
Web Developer
Fayette County Public Schools | Lexington, Kentucky, USA
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users