This topic is locked
[SOLVED]

 Current page label and record count in header

11/17/2009 2:02:49 PM
ASPRunnerPro General questions
T
Tim author

Hello,
I would like to display 2 things in the header: the label of the current page (the name that is highlighted in the menu) and a count of records in a certain table. Can this be done? Are the typical "include" files available in the header (like dbcommon.asp) or do I (can I) add them manually?
Here is the SQL statement that gets me the record count I need:

Select count(*) as new from RequestLog where RequestType is null
I assume I execute that, add the record set to a session variable, then write that to the page. I know how to do all this in the other pages, but does it work the same in the header? I assume it would take more code.
And is the page label variable (or whatever you call it) available in the header?
Thanks for your help.

Tim

J
Jane 11/19/2009

Tim,
to add VB code to the header use following sample:

<%

Response.Write "table: " & strTableName
str = "Select count(*) as new from RequestLog where RequestType is null"

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

Response.write "count: " & rstmp("new")

rstmp.close

set rstmp=nothing

%>
T
Tim author 11/19/2009

Hi Jane,
Thanks so much for the code. I had tried something similar, but I have problems when I try and add it to the Header in Visual Editor.
First, I cut and pasted your code in to the header while in Visual Editor desing mode. Not good: it added all the HTML tags and treated it like text. Ok, makes sense.
Then, in VE Header, I switched to "code" mode and paste it again. First thing I noticed is when I switched to design mode, then back to code, the code disappeared. But if I published the app, the header code was there.
When I browse I get this error:
ADODB.Recordset error '800a0bb9'

Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.

/MaintenanceRequests/include/header.asp, line 5
Then, I tried just the first line of your code:

<%

Response.Write "table: " & strTableName

%>
When I browse I only see table:

No table name. It seems these varibles are not available in the header... and maybe no connection string too...? Or am I doing something wrong?
Thanks,

Tim

J
Jane 11/20/2009

Tim,
Please publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages along with instructions on reproducing this error.

T
Tim author 11/23/2009

Jane,
I can, but I don't think that's necessary. I can reproduce this on any project. Here is how to recreate:
Go to Visual Editor, slecet Header page, click the "HTML Mode" button and type:
<%

Response.write "table: " & strTableName

%>
First problem: click on "Design Mode" button, then click back to "HTML Mode" button. Code is gone.
Second problem: put the code back in there, publish app, browse to any page. In the header you see the text "table:" but not the tabel name.
I hope this gives you enough to go on. Let me know if you need more info.
Thanks,

Tim

J
Jane 11/25/2009

Tim,
I see what you're saying.

Unfortunately Visual Editor do not support VB code.
You can edit generated include/header.asp file directly:

<!--#include file="dbcommon.asp"-->

<%

str = "Select count(*) as new from RequestLog where RequestType is null"

Set rstmp = server.CreateObject("ADODB.Recordset")

rstmp.open str,dbConnection

Response.write "count: " & rstmp("new")

rstmp.close

set rstmp=nothing

%>


There is no way to show current table name in header. You can use custom event only for this purpose.

T
Tim author 11/29/2009

Thanks Jane. I figured it was something like that. Editing the header file directly will work for me on this one.
Feature request: it'd be nice to have access to all the variables and db connections from the header and footer in the Visual Editor, like you do on the the menu page.
Thanks again.

Tim