Includes in ASP.NET

G

Guest

I'm a begginer at ASP.NET having developed for several years in ASP and
VBScript.

I am developing a website where I'm componetazing the header, content
section and the footer. Each secion is a different page.

My codes looks like something like this

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="default.aspx.vb"
Inherits="LDOL._default" %>
<html>
<!--#include file="header.aspx"-->
default page content here...
<!--#include file="footer.aspx"-->
</html>

My dilema comes when I have different functions in the header.vb page (such
as getting metatags from a db) that cannot be seen because the default.aspx
page looks for the function in the default.vb page instead. It returns an
error "Function not declared". I've tried to find a way where I can have all
my common functions in a centrailzed place (like the global.asax) but have
not been successfull. Am I trying to make ASP.NET do something that was a
shortcoming of ASP? That is what is seems to me...
 
G

Guest

Hi Dacuna,

There are much betters way in ASP.NET to achieve the same thing.

What you need is a web user control. There are trillions of tutorials on how
to do this on web. A web user control is a particle of reusable HTML combined
with code-behind. The only difference of the web user control from a normal
page is that first it's reusable and second it does not contain any html
header etc. See it as a part of the body of the main page. Then you can
expose methods on this user control to the main page in a simple way.

Perhaps you also need the following links to start with;

User Controls:

http://msdn.microsoft.com/library/d...n/html/vbconintroductiontowebusercontrols.asp

and even

Page object model:

http://msdn.microsoft.com/asp.net/u...objectmodel.asp#aspnet-pageobjectmodel_topic3


Hope this helps,

Ethem
 

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,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top