In the asp.net pages below, Common.vb has an overridable Page_Load sub. In
the consuming page, Two.aspx, the Page_Load sub is inherited, but for some
reason it (Overrides Sub Page_Load) executes twice.
In another "regular" asp.net page that inherits only from its own codebehind
page, the page load only executes once as you'd expect.
Any ideas why the page_load fires twice in the former example?
Thanks,
Brent
============
Common.vb:
============
Imports System
Imports System.Web.UI
Imports System.Web.UI.H tmlControls
Imports System.Web.UI.W ebControls
Public Class Common
Inherits Page
Protected WithEvents lblHeader As Label
Overridable Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
lblHeader.Text = "Overridabl e common text."
End Sub
End Class
============
Two.aspx:
============
<%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Com mon.vb"
Inherits="MyTes t.Common"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body>
<form method="post" runat="server">
<asp:Label Runat=server ID=lblHeader />
</form>
<script language=vb runat=server>
Overrides Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'mybase.Page_Lo ad(sender, e)
lblHeader.Text &= "<br>Page TWO Overriding page load<br><a
href='./one.aspx'>Back to Page One</a>"
end sub
</script>
</body>
</html> 1 3378
Try removing "Handles MyBase.Load" from both Common.vb and Two.aspx
"bminder" <bm*****@b2btec h.com> wrote in message news:<lv******* *************@s peedfactory.net >... In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes twice.
In another "regular" asp.net page that inherits only from its own codebehind page, the page load only executes once as you'd expect.
Any ideas why the page_load fires twice in the former example?
Thanks,
Brent
============ Common.vb: ============ Imports System Imports System.Web.UI Imports System.Web.UI.H tmlControls Imports System.Web.UI.W ebControls
Public Class Common Inherits Page Protected WithEvents lblHeader As Label Overridable Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load lblHeader.Text = "Overridabl e common text." End Sub End Class
============ Two.aspx: ============ <%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Com mon.vb" Inherits="MyTes t.Common"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <body> <form method="post" runat="server"> <asp:Label Runat=server ID=lblHeader /> </form> <script language=vb runat=server> Overrides Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'mybase.Page_Lo ad(sender, e) lblHeader.Text &= "<br>Page TWO Overriding page load<br><a href='./one.aspx'>Back to Page One</a>" end sub </script> </body> </html> This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Noah Coad [MVP .NET/C#] |
last post by:
How do you make a member of a class mandatory to override with a _new_
definition? For example, when inheriting from
System.Collections.CollectionBase, you are required to implement certain
methods, such as public void Add(MyClass c).
How can I enforce the same behavior (of requiring to implement a member with
a new return type in an inherited class) in the master class (similar to the
CollectionBase)?
I have a class called...
|
by: Mark |
last post by:
I have been working for quite some time on this issue which in theory
should be quite simple. The problem is that the Cancel and Save
events are not fired when their respective buttons are clicked.
I have read several posts which say to put your column generating
section in the Page_Init section and it will solve the
problem....however, it hasn't solved mine.
Can somebody please take a look at this and provide any insight if
possible?
|
by: Shane Bishop |
last post by:
I've been fighting with the Page_Load event firing twice.
I looked through this user group and saw several other people having
similar problems.
There were various reasons for it:
AutoEventWireup="true" instead of AutoEventWireup="false"
Spyware software
And having your events all wired wrong
I had done everything to my machine, stripped it down to just have
..NET on it and I was still having this problem until...
|
by: Jay Douglas |
last post by:
Hello all,
I have a asp.net page that creates a pdf on the fly and sends the pdf
down to the browser. When calling the page up in IE the Page_Load event is
fried twice. This doesn't happen with mozilla, just IE. This is a big
problem because the PDF can be 20+ MB in size and is causing some serious
performance issues. Writing the PDF to the filesystem then a redirect is
not an option. I was wondering if anybody has any input on how...
|
by: V. Jenks |
last post by:
I'm a little rusty having not touched .NET for 6 months and
I can't remember why Page_Load is happening twice in this code:
private void Page_Load(object sender, System.EventArgs e)
{
//existing session?
if (Session == null)
{
//save local empty order object
this._newOrder = Orders.Initialize();
| |
by: pat.allan |
last post by:
Hi All
This seems to be a common problem here, but I've not found a solution
yet to fix it for me.
When I request a page through a browser, the page_load fires once. When
I request the page's code-behind object via a custom handler and the
code-behind object's ProcessRequest method, it fires twice - both times
from the ProcessRequest call, as far as I can tell.
|
by: dbuchanan |
last post by:
Hello,
I can find no reason for this code to run twice. Can you help me?
It may have something to do with it being a overrides sub but stepping
through during debug does *not* bear this out.
In the base class form...
\\
|
by: johncee |
last post by:
Greetings,
I created a base class that has a datagrid. I've made it generic as
possible so that any derived classes pass some info to the base
constructor (including a SQL select stmt) & through the base class, any
db table can be displayed/maintained in the grid.
I've made some of the base class' event-handling subs overridable and in
some of the derived classes using the base, the subs are being
overridden:
|
by: Jerry |
last post by:
Hi,
My app is controled by a treeview.
Each node brings a subform for input and calculations to the front. The
subforms are loaded as controls on the main form.
Dim ctl As Control
For Each ctl In Me.Controls
If TypeOf ctl Is Form Then
|
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: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
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...
| |