Use server events to create custom headers and footers

Tips submitted by ASPMaker users

Use server events to create custom headers and footers

Postby squeek » Sat Aug 23, 2014 8:38 am

I'm working on a large project that uses four separate web addresses for four different functions, but all hitting the same database. I needed to be able to put help text in the header, and/or in the footer of some of my list/add/edit/view pages for some of my tables, AND I needed the help text in three languages, AND I needed the client to be able to enter that help text themself on their admin site, so I made it data driven.

Table helptext
Fields id - identity, tablename nvarchar(50), pagenvarchar(50), headfootnvarchar(50), English nvarchar(max), Spanish nvarchar(max), Vietnamese nvarchar(max)

Tablename should hold the name of the table or view. Headfoot can be head or foot.
Page can be list, add, edit, or view. For example, for a header on the list page of the applicants table, the record would look like this:

and then the english text, spanish text, and vietnamese text

This is a pretty simple layout. Now for the code.

In the global/all pages/page_head code, add these functions:

function gethelp(table, page, headfoot, language)
dim strsql
strsql="SELECT " & language & " as helptext from helptext where lower(tablename)='" & lcase(table) & "' and lower(page) = '" & page & "' and lower(headfoot) = '" & lcase(headfoot) & "'"
gethelp=replace(ew_ExecuteScalar(strsql) & "",vbcrlf,"<br><br>")
end function

sub showhelp(table, page, headfoot)
if gethelp(table, page, headfoot, "english") & gethelp(table, page, headfoot,"spanish") & gethelp(table, page, headfoot, "vietnamese") & "">"" then %>

<link rel="stylesheet" href="//">
<script src="//"></script>
<script src="//"></script>
<link rel="stylesheet" href="/resources/demos/style.css">
$(function() {
$( "#help<%=headfoot%>" ).tabs();

<div id="help<%=headfoot%>">
<li><a href="#help<%=headfoot%>-1">English</a></li>
<li><a href="#help<%=headfoot%>-2">Spanish</a></li>
<li><a href="#help<%=headfoot%>-3">Vietnamese</a></li>
<div id="help<%=headfoot%>-1">
<%=gethelp(table, page, headfoot,"english")%>
<div id="help<%=headfoot%>-2">
<%=gethelp(table, page, headfoot,"spanish")%>
<div id="help<%=headfoot%>-3">
<%=gethelp(table, page, headfoot,"vietnamese")%>
end if
End Sub

For each table and page where you might want a header or footer, enter this into the Page_DataRendering sub:

showhelp "applicants","list","head"

and this into the Page_DataRendered sub:

showhelp "applicants","list","foot"

Make sure you enter your tablename and page type as appropriate.
Posts: 31
Joined: Fri Nov 22, 2013 2:31 am

Return to User Submitted Tips (ASPMaker)