SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software Kodyaz Development Resources
Development resources, articles, tutorials, code samples and tools and downloads for ASP.Net, SQL Server, R Script, Windows, Windows Phone, AWS, SAP HANA and ABAP, like SAP UI5, Screen Personas, etc.

Software Development



ASP.NET pages load twice and passes the Page.IsPostBack control statement

Hello,


I had a problem with loading an ASP.NET page twice recently. I knew from my previous experiences with such a problem that one of the main reasons that cause loading an ASP.NET page twice is the AutoEventWireup attribute of the page declaration in ASP.NET pages.

If AutoEventWireup attribute is set to True and if you are using an IDE like MS Visual Studio in your development environment, since Visual Studio automatically binds events to controls and because of AutoEventWireup attribute is True identifiying page events to be wired up automatically, each event triggered is processed twice on the server side.

But there is one reason causing events defined to be triggered twice on the server side. I think this happens when you copy and go editing on an existing asp.net web page on the Microsoft Visual Studio 2005 or VS2008 rapid development IDE environments.

Here is the reason I'm trying to mention above.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load

You see Page_Load event is defined twice for MyBase.Load and Me.Load (Page.Load) events. So it runs twice and even if you try to control the flow of the process using Page.IsPostBack property you will fail to prevent the execution of the Page_Load sub routine twice.

Removing the MyBase.Load will work successfully in this case.

Published Saturday, July 05, 2008 4:52 PM
Filed Under: ,

Comments

No Comments
Anonymous comments are disabled

About eralper

SQL Server administrator and T-SQL developer including BI components Web programming with HTML, HTML5 and ASP, ASP.NET and .NET Framework developer SAP ABAP and SAPUI5 development, Web Dynpro and Smart Form Siemens HiPath Center CTI development
Copyright © 2004 - 2020 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems