Hi all,
I have two aspx pages:
Default.aspx with its code behind page of Default.aspx.vb
Home.aspx with its code behind page of Home.aspx.vb
The Default page in effect is just a template, the Home page will be the same but with some extra functionailty. I dont want to have to copy the code from the Default.aspx.vb to the Home.aspx.vb page since I assume there is a more efficient way.
Ive tried to inherit the Default code into the Home code like so:
Default.aspx.vb -
Public MustInherit Class DefaultCode
-
-
Inherits System.Web.UI.Page
-
Home.aspx -
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Home.aspx.vb" Inherits="DefaultCode" %>
-
Home.aspx.vb -
Partial Class Home
-
-
Inherits DefaultCode
-
Now that just doesnt seem to be working, it doesnt seem to recognising what the DefaultCode is when im telling it to inherit it.
If i move the Default.aspx.vb into the App_Code file (im using Visual Web Developer) Home.aspx.vb inherits DefaultPage but Home.aspx wont run, there loads of errors.
Thanks, Ash.
5 1586
Have you thought about creating a user control that will be used on both pages? The user control would contain the common functionality of the two pages. To me this would be an easier solution.
Nathan
Ya it's true user controlls are very useful and best way to accomplish you desired task.....
Um...am I missing something here? Wasn't the Master pages concept developed (at least in part) for this purpose? Put all your common code, stylesheet, etc etc in the Master page, when you create a new page, select the "Select master page" option and create page content...
Ben
Thank you all.
I thought masterpages were just for the HTML side of things?
Ive never used one, ill try one out after ive tried using user controls, another thing ive never used, any idea on how they would work in my case? any help would be appreciated, thanks.
User controls are fabulous when you want to dynamically use templates for objects on your page, when you build a user control, think of it somewhat like an active-x control or a class in that you can create properties which set/get values inside objects within that user control. The user control would hold code in its codebehind that pertains only to functions pertaining to that user control.
My personal opinion is that for templating whole pages, this isn't really the way to go - others may or may not disagree with me but I look at master pages, pages and user controls somewhat as a hierarchy. Where each of my user controls contains one or more controls/user controls; pages hold a bunch of user controls and a master page holds a template for a bunch of pages to provide centralized management of look and feel of your site, including global methods and scripts that should be available across the whole site.
As I said though, that's just my personal opinion, and doesn't mean that either way is more right or wrong than the other.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Steve |
last post by:
Visual Studio 2003 .Net / C#
I have a 2 page Tab Control for users to add a Job in my application. The
first page is for them to choose which type of Job they would like. The type
of Job determines what information is asked for on the second page, and so
will determine the layout of the second page. So this second page needs to
be determined at runtime really when they select the Job Type on page 1. I
thought I could maybe define...
|
by: Jeff |
last post by:
Greetings
I am beginning a web app. I am using C# aspx forms for my web pages.
Is it possible to create/use one aspx file as a base from which to
derive other aspx files? I can not get this to work.
What I tried was this:
Create a new web project.
- rename WebForm1.aspx to MyBase.aspx
- Add (grad from tool box) a label to the html form
- Then create another aspx file (using "Add Web Form"). This produces
WebForm2.aspx.
|
by: Ben Mann |
last post by:
Hi there,
I am starting on an ASP .Net project. I have some examples of using a base
class for pages to inherit from to allow additional properties to be used by
default. This seems like a good idea to me.
I have a namespace Company.Web. I have created a PageBase.vb file with a
PageBase class containing the the properties required. This class also
inherits the System.Web.UI.Page class.
|
by: David |
last post by:
I have trying to have a webform inherit controls from another form and can't
get it to work
Say I have a form that saves the person's demographic info.
****one.aspx****
//I have an object to save the person's name in code behind
protected void SavePersonInfo(Person p)
|
by: tshad |
last post by:
I am just trying to decide whether to split my code and uses code behind. I
did it with one of my pages and found it was quite a bit of trouble.
I know that most people (and books and articles) like it because you can
split the code from the design. That is logical. But if you are the only
one working on the code, it seem a little overkill.
I use Dreamweaver to do my design and find it a bit of a hassle to have
multiple files open...
| |
by: mister.mwa |
last post by:
Hello,
I have the following problem:
I have a class Foo, and a class Bar.
I want Foo to inherit from Bar, but i want to put them in separate
files Foo.vb and Bar.vb. Then i will use the Foo Class in a code behind
separate file called CodeBehind.vb
Then i will use this CodeBehind normally in mypage.aspx.
|
by: ad |
last post by:
We can inherit a class.
But if the class is the code behind, when we inherit it , can we inherit
it's aspx ahead together ?
|
by: Randall Parker |
last post by:
I've noticed that C# can only inherit from a single class. At the same time, the
CodeBehind in an aspx.cs file inherits from Page.
So what do you all do to reuse code in .aspx.cs classes?
Seems to me one has to create classes and make them members of classes in the aspx.cs
files.
Is that what you all do? (at least those of you who try to get re-use)
|
by: rn5a |
last post by:
Assume that a user control (MyUC.ascx) encapsulates 2 TextBoxes with
the IDs 'txt1' & 'txt2' respectively. To use this user control in an
ASPX page, the following Register directive will be required:
<%@ Register TagPrefix="UC" TagName="MyUserCtrl" Src="MyUC.ascx" %>
Assuming that the ASPX page doesn't use a code-behind, I can access the
properties, events etc. of the user control in the ASPX page in this
way (assume that the ASPX page...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |