How To Call Function ...

T

Tiraman

Hi ,

I have 3 files ,
middle.aspx file include the header.aspx and footer.aspx files .
in each of the include files there is a function and from some reason the
call to the Footer() function from the Header.aspx file works fine
But The Call From The Footer.aspx file to the Header() function doesn't work
bcz of some
Compiler Error Message: BC30188: Declaration expected

Please Advise .

Here is the code :


Middle.aspx
**********
<!--#include file="Header.aspx"-->
Some Code Here ....
<!--#include file="Footer.aspx"-->


Header.aspx
**********
Function Header() As Boolean
'do nothing
Header = True
End Function


Footer.aspx
*********
Function Footer() As Boolean
'do nothing
Footer = True
End Function
 
M

[MSFT]

Hi Tiranman,

Are the functions "Header" and "Footer" client side functions? If so, you
may not be able to call them in that way. When the function in Header is
executed, the footer's code hadn't been load in client browser (IE).
Therefore, we will get an error. For more information abut included ASPX
page, you may refer to:

HOW TO: Dynamically Include Files in ASP.NET
http://support.microsoft.com/default.aspx?scid=kb;EN-US;q306575

Additonally, if you want to add a header or footer on an ASPX page, you
also can consider add them as ASP.NET web control or iframe component.

hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
T

Tiraman

Hi Luke ,

The Functions Are Server Side and i don't want to use a dynamically includes
..

i want that those 2 files (header & footer) will be in all of my aspx files
and they Page_Upload is in them
which mean that the page will start to work from the Header to the Footer
and when the footer will be process there is a function
that call function which is in the header but as i wrote i m getting error .

Please Advice

10x
 
M

[MSFT]

Hi Tiraman,

I studied the code and found the root cause is following code ahdn't been
place in pre-defined function:

Dim bResult As Boolean = False
bResult=VerHeader()
Response.Write("Header = " & bResult)

In Header.ASPX, your code is in Page_Load (a pre-defined sub in asp.net),
so that it can be executed. However, above code hadn't been placed in such
a sub. The error "BC30188: Declaration expected" is for Response object,
not for the function "VerHeader". To test this, you may change above code
to:

Dim bResult As Boolean = VerHeader()

This won't cause the error.

Response/Request object are only avaliable in pre-defined sub like
page_load or Button_Click.

If you need to outpput something in the Header/Footer, I strongly recommend
you use a ASP.NET web cotrol intead a included file.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
T

Tiraman

Hi Luke ,

10x for the explanation about the pre-defined sub and so on .
it really work when i m using your example and right now my header hold lots
of general functions which i am
using all of the pages and the footer is empty but if one day i will need it
i will be able to use it without going over the pages and put it there :)

i will also consider to use the web control as you recommended but first i
need to read about it in order to get a good understanding .

10x again for your help .

bye

Tiraman .
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top