will Page_Load execute in both web form and its base page?

Thanks in advance for your help.

 I'm creating an ASP.NET project using Visual Studio 2005.   All the individual web content forms inherit from a BasePage class, which in turn is of type System.Web.UI.Page.

 The BasePage declares some variables like SqlConnection, SqlCommands, etc that are global to all pages in the site.  The BasePage also overrides the Page_Load method, where I've added a few lines of code that I'd like to execute any time that any page in the site comes up.  The Page_load override checks that the user has authenticated if it's a secure page, etc.

I'm noticing that if I override Page_Load in the base page, the individual Base_Page method on the individual pages is not coming up.  This doesn't seem right, in other sites I've done (.NET 1.1) I believe the Page_Load method executed in both the PasePage and the inherited web form.

 Also, when I create a new class in the project, the code file is not automatically being dropped into the App_Code folder.  In fact, I had to create the App_Code directory manually and drop all my classes, dataset, etc, in by hand.  Is this normal behavior?

 Thanks in advance,

 Andre Ranieri

6/13/2007 2:10:28 AM
asp.net.getting-started 91979 articles. 4 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 22
Get it on Google Play
Get it on Apple App Store

Don't override the Page_Load method in either your BasePageClass or your derived class, that way both Page_Load methods will be called. So you just want to define the following method in the base class and any deriving classes that need to handle the Page_Load event:

protected void Page_Load(object sender, EventArgs e)


If you do override the Page_Load method in a derived class you will need to call base.Page_Load (or some similar syntax to force the base method to fire.)

The class files should be placed in the App_Code folder by default, that is definitely strange behavior you are seeing in VS 2005.


ASP.NET Weblog

Personal Blog

My Business
6/13/2007 3:40:47 AM


 Thanks a bunch for your help!  I've been staring at code way too long today.

 Andre Ranieri

6/13/2007 4:04:33 AM


 Thanks a bunch for your help!  That worked out great.   I've been staring at code way too long today.

 Andre Ranieri

6/13/2007 4:05:04 AM

Similar Artilces:

getting start with vb.net and crystal repots(web form)
I use Crystal Report9 in Visual Studio.NET 2003..... Example at Northwind database I want a application that.....a form include a combobox that contain CustomerID.....If I choose one CustomerID and click OK button....a Report will display information about this Customer......I think that must use Paramater.....how to do that ???? (How do I start to coding --please step by step or sample) please help me !!! Thank you so much!!! very good I have Dropdownlist when I choose the 'month'--> the all data of this field will show I use this Private Sub ddlMonth_Sel...

Can my web page with a form submit to other web pages forms?
I was wondering if I created an aspx page that had a form on it that I could use the submit button to submit this form's contents to other web pages forms(servers accepting those form's data). I am thinking this would be a great way to update data on particular web pages without having to actually visit those similar web pages. Any ideas, examples would be much appreciated. Thanks in advance.  Yes you can.  It's called Cross Page Posting: http://msdn2.microsoft.com/en-us/library/ms178139.aspxAlso: http://msdn2.microsoft.com/en-us/library/ms178140.aspx might ...

VB .net Web Form will not get contents of Text Box
I have created a web form with text boxes that are bound to a DataSet/DataView.  I have created button to navigate up and down the recordset.  That all works fine. I need to have the ability to edit/add text in any of the boxes and then when clicking "Save" button, it would build an UPDATE query to send to the database. When the Save button is clicked, I have coded to DIM a string var (strSQL) to use to build the SQL command.  For some reason, it will only get the text from a text box if the data was pulled the database.  If I add/edit data, then the SQL command will ha...

Do not get expected WEb page on secondary
netware 6.5 sp2 Have setup a web page on a seconary IP address Load appache with the following command line LOAD ADDRESS SPACE = CSMI APACHE2 -f SYS:APACHE2\CSMI\SERVER\HTTPD.CONF Where HTTPD.CONF is set up to Listen which is a secondary ip address A display secondary ipaddress at the server lists the seconary ipaddress I can ping the secondary ip address from the client in Remote manager using IP Address management the secondary IP addresses are not listed When I attempt to brose to the HTTP:// address I do not see the web page I...

Could PB .NET Web Form POST security Information to others web page??
This is a multi-part message in MIME format. ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/plain; charset="big5" Content-Transfer-Encoding: quoted-printable Hi,=20 Have anyone came across the requesion to POST security informations from = PB .NET web form web page to other web site?? I have tried many datys, Could any kind man give me some suggessions?? thanks & Best regards Leon ------=_NextPart_000_00F9_01C9C4D5.8FB45C90 Content-Type: text/html; charset="big5" Content-Transfer-Encoding: quoted-printable <!DOCTYPE HTML P...

How to get HTML Source of web page opened by web browser using vb.net
hello friends,         i have opened an web browser in vb.net using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim nullObject As System.Object = 0 Dim str As String = "" Dim nullObjStr As System.Object = str Windows.Forms.Cursor.Current = Cursors.WaitCursor Dim i As Int16 For i = 1 To 2 AxWebBrowser1.Navigate("http://www.google.co.in/search?hl=en&q=test&meta=", True) AxWebBrowser1.Document. Next Windows.Forms.Cursor.Current = Cursors.Default End Sub  ...

Can a .NET 1.1 page execute in a .NET 2.0 web site?
I've got a ASP.NET 1.1 web site to which I would like to add some ASP.NET 2.0 web pages. Could I just change the web site to point to the 2.0 .NET version and still have the .NET 1.1 web pages work so that both versions are in the same web site? Have you some of you approached this? Thanks. The official answer is maybe It's not officially supported, but most ASP.NET 1.1 pages will run fine under ASP.NET 2.0.  Officially you should run the upgrade wizard on your 1.1 pages. This is a  pretty good blog entry.      JamesMy Blog: http://www.wintersfamily.plus.c...

how to open a web page in form of a popup web page
Hello, I have two web pages, let say. Page A : With a Button on it. PAge B: with some info. Now I need to: When I click on the Button of page A.Page B must open in a pop up window.  I can do this but problem is this when I clicked on the button for first time it does not show me any thing and when I clicked on the button for second time then It shows me Page B .My code is as follow:  1 protected void Page_Load(object sender, EventArgs e) 2 { 3 if (!this.Page.IsPostBack) 4 { 5 6 } 7 else 8...

How to get the HREF value of the Anchor tag in a web page using the web browser control in vb.net
Hi Friends,               i have a webserver control in my application.i load the web browser control on a button click using the below code Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click                AxWebBrowser1.Navigate("http://www.rateitall.com/i-322335-.aspx", False) End sub once the page is loaded in the browser i want the <a> HREF value in that page.For example if that page has ...

Getting things back in Start Page and things out of Start Page
I know I posted over a year ago about this same question, I can not find my original post though. I know I posted it and I did find the solution and posted the sollution but I can not find it anywhere here again. They really need a better search engine on these forums. Is there any tools out there to help manage the start page? For example. I have projects that are on a web server I access them on the remote server. Well the start page never ever shows any updates for it the date posted as last access is the day I created it, However this is one of my more used projects. This one is so b...

Is there a way to add MVC to an existing web-forms-based web site so that the old .aspx pages still work alongside MVC?
I have an existing web site that needs to continue working in its old fashion as I make updates to it. I want to add the MVC framework to the web site, and then, as time permits, I want to be able to convert the original web forms-based pages into MVC-style actions/urls/views/etc. All the while, having both styles of pages working at the same time, so that I could for example update one section of the web site to use MVC and leave the rest of the site still using the web form style. Is this possible? Is it just as easy as doing it, or is there some special configuration t...

executing Windows forms from web page
Is this possible to do this? I would like to execute a painting program from the web so I can manipulate an image from a browser. Chopps http://www.15seconds.com/issue/030610.htm thanks for the link!Chopps I have a little paint program that I want to run via a webpage. Its a GDI+ app that would allow people to use it without having to download the .EXEChopps...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

Open web page in IE and populate fields on the form from my web form
To the dot net Knights.  Many humble thanks in advance from a dot net surf. We have an vb application that opens multiple instances of IE object, each to different web pages.  It then takes information from the current record in the app, populates fields on each of the web pages, and them submits the forms.  We are then able to look at the resulting web pages and quickly get the info we're looking for.This prevents us from having to manually navigate to each web site, enter the same information and then wait for the page to open.  If there is ...

Web resources about - will Page_Load execute in both web form and its base page? - asp.net.getting-started

ASP.NET - Wikipedia, the free encyclopedia
ASP.NET is a server-side Web application framework designed for Web development to produce dynamic Web pages . It was developed by Microsoft ...

Delivering NSW rugby fans the latest news, rugby match fixtures & results, video and rugby statistics for the Shute Shield - NSW Premier Rugby ...

操作失败信息_Foosun Inc.
System.IO.FileNotFoundException: Could not find file 'D:\wwwroot\2011askci\CIlucenet\search_reports\_1bv.cfs'.File name: 'D:\wwwroot\2011ask ...

FAIL can impress, too
I mentioned that a quick way to setup things for me to think that a candidate is a bad idea is to send us a UI project. This is usually a very ...

C# dotnet SQL editor (codebehind side)
... editor (webform side) I've explained the purpose of this "exercise" and suggested a webform proposal for this diy SQL... protected void Page_Load(object ...

Silverlight, FireFox and 100%
In my last post I mentioned something nice about FireFox. In this post I’ll talk something not that nice about FireFox and the way we, more or ...

Case insensitive compare on string in ASP.NET - Coders Grid
... ; using System.Web.UI.WebControls ; namespace WebApplication1 { public partial class Compare : System. Web . UI . Page { protected void Page_Load ...

Response.Redirect() executes too soon on the Server.
-*+I’ve seen this question a couple of times in various situations. The first involves Javascript and the second involves server side code. Both ...

Boost ASP.NET performance with deferred content loading
A comprehensive example of how to improve the perceived speed of your pages, by implementing user controls to encapsulate secondary content and ...

Visual Studio 11 Beta in Context
... partial class Categories : System.Web.UI.Page { private readonly DemoWhateverDataContext _db = new DemoWhateverDataContext(); public void Page_Load() ...

Resources last updated: 12/25/2015 9:40:44 PM