473,320 Members | 2,098 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

? - AutoEventWireup="true" - What is this really doing?

I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I 'run' the application, I get two treeviews instead of one. I'm thinking this is because of the AutoEventWireup property being set to true.

1. Am I correct? If so, if the AutoEventWireup property is true, why does it create two treeview in my user control?

2. If I set the AutoEventWireup property to false, what issues/problems will this cause (if any)? And, what else do I need to do to make sure my user control works correctly?

Thanks in advance for your help.

Nov 18 '05 #1
2 3592
From ASP.NET Server Control Event Model (help file)
If you do set AutoEventWireup to true, Visual Studio will generate code to bind the events and the page framework will automatically call events based on their names. This can result in the same event code being called twice when the page runs. As a consequence, you should always leave AutoEventWireup set to false when working in Visual Studio.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** *************
Think outside the box!
************************************************** *************
"Guy Lafleur" <gl****@yahoo.com> wrote in message news:O3*************@TK2MSFTNGP09.phx.gbl...
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I 'run' the application, I get two treeviews instead of one. I'm thinking this is because of the AutoEventWireup property being set to true.

1. Am I correct? If so, if the AutoEventWireup property is true, why does it create two treeview in my user control?

2. If I set the AutoEventWireup property to false, what issues/problems will this cause (if any)? And, what else do I need to do to make sure my user control works correctly?

Thanks in advance for your help.

Nov 18 '05 #2
This is straight from docs:

"
The ASP.NET page framework also supports an automatic way to associate page
events and methods. If the AutoEventWireup attribute of the Page directive
is set to true (or if it is missing, since by default it is true), the page
framework calls page events automatically, specifically the Page_Init and
Page_Load methods. In that case, no explicit Handles clause or delegate is
needed.
The disadvantage of the AutoEventWireup attribute is that it requires that
the page event handlers have specific, predictable names. This limits your
flexibility in how you name your event handlers.
"

So to speak, if you have AutoEventWiureUp="true" as well as manually
attached Page_Load method to handle Load event, it gets called twice
(actually handling the event and second via the automatic event wiring
basedf on event name). If you create yout TreeView dynamically in Page_Load
and method gets called twice, result is as you described.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
"Guy Lafleur" <gl****@yahoo.com> wrote in message
news:O3*************@TK2MSFTNGP09.phx.gbl...
I have a user control that builds a treeview dynamically in the Page_Load
event. Also, I have the AutoEventWireup property set to true (i.e., <%@
Control AutoEventWireup="true" %>). Then, when I 'run' the application, I
get two treeviews instead of one. I'm thinking this is because of the
AutoEventWireup property being set to true.

1. Am I correct? If so, if the AutoEventWireup property is true, why does
it create two treeview in my user control?

2. If I set the AutoEventWireup property to false, what issues/problems
will this cause (if any)? And, what else do I need to do to make sure my
user control works correctly?

Thanks in advance for your help.
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
2
by: Tee | last post by:
what's the differences between "Overrides Sub OnError" and "Sub Page_Error" ?
2
by: mawi | last post by:
Hi there, When removing page children controls created dynamically not in last-to-first order, the close button of the last control looses its event wiring, even though the handler is rewired...
2
by: magister | last post by:
Does smartnavigation on parent page make user controls page_load twice... Any fixes for this!!! Problem is when boss sees smartnavigation he likes but it causes lots of other bugs....why...
0
by: xs | last post by:
I have a master page which has a class name "GlobalPage" created in Web namespace. I created a string property called connectionString in this GlobalPage class. I have a ascx control loaded in...
6
by: antonyliu2002 | last post by:
Right now I put my VB code in the aspx pages. I would prefer to use codebehind, especially many of my VB functions may be shared across multiple aspx pages. I've tried a few pages with...
2
by: sck10 | last post by:
Hello, Is there an equivalent to using "Handles" in the codebehind for c#? Or do I have to declare every event in the GridView control like the following: <asp:GridView ID="gvSearchList"...
3
by: Michael | last post by:
Hi, I am getting a strange error. Last night when I left work this was working perfectly. This morning when I try to run this code in VS2005, it comes up with an error saying "The name 'UserName'...
5
by: celoftis | last post by:
Using VS2005 ASP.NET 2.0, VB code behind: I have a windows forms based application that I need to port to the web. One of the major components of my windows forms based application is a TreeView...
6
by: =?Utf-8?B?U2NvdHQgVHJpY2s=?= | last post by:
I followed the instructions from MSDN for Webclient UploadFile and I get an error: Could not find file 'C:\testfile.xls'. If I add the file (c:\testfile.xls) to the server I do not get the error...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.