473,395 Members | 1,341 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,395 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 3595
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...

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.