Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ? - AutoEventWireup="true" - What is this really doing?

Reply
Thread Tools

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

 
 
Guy Lafleur
Guest
Posts: n/a
 
      04-06-2004
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.

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\) [MVP]
Guest
Posts: n/a
 
      04-07-2004
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" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
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.

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      04-08-2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
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.


 
Reply With Quote
 
sjr.priyanka sjr.priyanka is offline
Junior Member
Join Date: Oct 2011
Posts: 4
 
      10-10-2011
See nice article on AutoEventWireup:

http://www.expertsblog.in/post/AutoE...in-ASPNET.aspx
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
really interesting... or really dull. (depends on your attitude) TrevorBoydSmith@gmail.com Java 2 09-01-2006 04:38 PM
OT : But help really really needed re: Domain Name selling, hosting etc. problem nc HTML 1 02-03-2005 07:24 PM
REALLY REALLY WERID PROBLEM!!!!pls take a look Amir ASP .Net 3 01-23-2004 06:01 PM
really really mysterious IE6 problem--secure site ultraviolet353 Computer Support 7 11-22-2003 07:56 PM
MR. ED REALLY, REALLY LOVES THE D60 !!! Annika1980 Digital Photography 9 10-28-2003 04:53 PM



Advertisments