ASP .NET and ASP style confusion. Immediate solution required

G

Guest

Hi all,

Consider the following ASP program.


`````````````
OLD ASP STYLE
`````````````

~~~~~~~~~~
header.inc
~~~~~~~~~~

<html>
<body>
<table .......>
<tr>
<td><%=DEFINED_VAR%></td> <!-- DEFINED VAR WILL BE DEFINED AT THE TOP
OF EACH PAGE -->
</tr>
</table>

~~~~~~~~~~
footer.inc
~~~~~~~~~~
</body>
</html>


~~~~~~~~~~
index.asp
~~~~~~~~~~
<%@ Language="VB" %>
<%
Dim DEFINED_VAR
DEFINED_VAR = "Print this"
%>
<!-- #include file="header.inc"-->
<!-- #include file="footer.inc"-->




`````````````
..NET STYLE
`````````````

~~~~~~~~~~
header.ascx
~~~~~~~~~~

<%@ Control language="VB" AutoEventWiredUp=False
Codebehind="HeaderControl.aspx.vb" %>

<html>
<body>
<table .......>
<tr>
<td><%=DEFINED_VAR%></td> <!-- It reports me an error at this point -->
</tr>
</table>



~~~~~~~~~~
footer.ascx
~~~~~~~~~~

<%@ Control language="VB" AutoEventWiredUp=False
Codebehind="FooterControl.aspx.vb" %>

</body>
</html>



~~~~~~~~~~
index.aspx
~~~~~~~~~~
<%@ Page Language="VB" Codebehing="Page.aspx.vb" AutoEventWiredUp=false %>
<%@ Register TagPrefix="Pagination" TagPrefix="Header" src="header.ascx" %>
<%@ Register TagPrefix="Pagination" TagPrefix="Footer" src="footer.ascx" %>

<%
Dim DEFINED_VAR
DEFINED_VAR = "Print this"
%>

<Pagination:Header id="header1" runat=server />
<Pagination:Footer id="footer1" runat=server />


Note: What I want to do is to pass the DEFINED_VAR in header.ascx file,
similar to OLD ASP scenario.

How can i achieve that in .NET

Your help is immediately required.
 
S

Scott Allen

Does the value of DEFINED_VAR change on each request or is it more of
a configuration settings?

If it is constant, you could make the variable the static member of a
class (shared member in vb.net).

Otherwise, you could store a value in the Context.Items collection, it
is useful to communicate state during the processing of a single
request.
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top