473,857 Members | 2,065 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VS 2005 : why is the default for AutoEventWireup different for C# and VB.NET ?

OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following Page directive is inserted
:

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb" Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for VB.NET and "true" for C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically, where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first time
I see that two .Net languages need different settings to handle a .Net application.

Juan T. Llibre
ASP.NET MVP
============
Dec 14 '05 #1
5 3576
Oh ya, and I changed my c# templates to have it to false and override onInit
and onLoad

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uG******** *****@tk2msftng p13.phx.gbl...
OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following
Page directive is inserted :

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb"
Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page
directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for
VB.NET and "true" for C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically,
where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a
break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to
understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do
with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in
VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first
time
I see that two .Net languages need different settings to handle a .Net
application.

Juan T. Llibre
ASP.NET MVP
============

Dec 14 '05 #2
I can give you one answer. Not sure if it's accurate, but it makes sense to
me.

It's easier in the VB.Net editor to override a class member. As you know,
VB.Net offers those 2 nice little dropdowns which let you pick the class and
member you which to implement/overwrite.

The C# IDE doesn't provide this fascility. Therefore, it might have been
decided that it'd be best to use the simpler AutoEventWireup for C#. Users
don't have access to the nice IDE feature, so let's make the name easier to
remember.

The one argument against my guess is that C# intellisense allows for easy
overriding, but it's still not as easyas the VB.Net one.

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uG******** *****@tk2msftng p13.phx.gbl...
OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following
Page directive is inserted :

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb"
Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page
directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for
VB.NET and "true" for C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically,
where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a
break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to
understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do
with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in
VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first
time
I see that two .Net languages need different settings to handle a .Net
application.

Juan T. Llibre
ASP.NET MVP
============

Dec 14 '05 #3
That's the most sensible thing to do, given the current state of things.

I wonder why the VS Dev Team decided on different defaults
for the two languages, given that it's a relatively simple thing to
fix so that the defaults are standardized across languages ?

i.e., if the default for c# were to be "false", it would be just as easy to flip it
back to "true", but at least there would be a standardized default for both languages.

I think I'll bug it and see if we can get a standardized default for both languages.


Juan T. Llibre
ASP.NET MVP
============
"Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in message
news:uP******** ******@TK2MSFTN GP12.phx.gbl...
Oh ya, and I changed my c# templates to have it to false and override onInit and onLoad

Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uG******** *****@tk2msftng p13.phx.gbl...
OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following Page directive is
inserted :

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb" Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for VB.NET and "true" for
C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically, where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first time I see that two .Net
languages need different settings to handle a .Net application.
Juan T. Llibre
ASP.NET MVP
============

Dec 14 '05 #4
vb and c# have different syntax for linking event handlers.

in vb:

'* declare control
dim withevents mycontrol as new Control()

'* declare handler - the handles clause link the event to the contol
sub myHandler (sender as object, arg as System.EventArg s) handles
mycontrol.Click
end sub
in c#

// declare control

private Control mycontrol = new Control();

// declare function

void myHandler (object sender, System.EventArg s arg)
{
}

// auto wireup generate the following statement in the init code
// so that the onclick event calls the handler

mycontrol.Click += new System.EventHan dler(myHandler) ;
in asp 1.1 because the vs ide generated the wireup code, so you always set
autowireup to false.
-- bruce (sqlwork.com)
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uG******** *****@tk2msftng p13.phx.gbl...
OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following
Page directive is inserted :

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb"
Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page
directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs"
Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for
VB.NET and "true" for C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically,
where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a
break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to
understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do
with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in
VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first
time
I see that two .Net languages need different settings to handle a .Net
application.

Juan T. Llibre
ASP.NET MVP
============

Dec 14 '05 #5
Hi, Bruce.

You're exactly right, of course.

Let me add what Scott Guthrie said about this :
-----------------------------------------------
The VB language supports the "handles" statement -- which allows you to
wire-up the bindings to event handlers on the event handler methods themselves.

Although you can also explicitly wire-up event handlers using the server control
declaration (onclick="butto n1_click"), we've found that VB developers typically
expect/prefer using the Handles keyword instead.

C# as a language doesn't have a concept like the "handles" keyword.
Instead, you must explicitly wire-up event definitions.
-----------------------------------------------

So, the default setting of "false" for VB.NET seems to be
a question of choice while the setting of "true" is needed for C#.

i.e., VB developers can use either method but C# developers must explicitly wireup events.


Juan T. Llibre
ASP.NET MVP
============
"Bruce Barker" <br************ ******@safeco.c om> wrote in message
news:ua******** ******@TK2MSFTN GP11.phx.gbl...
vb and c# have different syntax for linking event handlers.

in vb:

'* declare control
dim withevents mycontrol as new Control()

'* declare handler - the handles clause link the event to the contol
sub myHandler (sender as object, arg as System.EventArg s) handles mycontrol.Click
end sub
in c#

// declare control

private Control mycontrol = new Control();

// declare function

void myHandler (object sender, System.EventArg s arg)
{
}

// auto wireup generate the following statement in the init code
// so that the onclick event calls the handler

mycontrol.Click += new System.EventHan dler(myHandler) ;
in asp 1.1 because the vs ide generated the wireup code, so you always set autowireup to false.
-- bruce (sqlwork.com)
"Juan T. Llibre" <no***********@ nowhere.com> wrote in message
news:uG******** *****@tk2msftng p13.phx.gbl...
OK, guys, usually I answer questions instead of asking them,
but this thing has me scratching my head.

Why is the default for AutoEventWireup different for C# and VB.NET ?

In VS 2005, if I create a new VB website using code-behind, the following Page directive is
inserted :

<%@ Page Language="VB" AutoEventWireup ="false" CodeFile="Defau lt.aspx.vb" Inherits="_Defa ult" %>

If I create a new C# website using code-behind, the following Page directive is inserted :

<%@ Page Language="C#" AutoEventWireup ="true" CodeFile="Defau lt.aspx.cs" Inherits="_Defa ult" %>

Is there a reason for AutoEventWireup 's default setting being "false" for VB.NET and "true" for
C# ?

I asked this over at the MSDN forums, and PeteL told me this :

"The short answer to your question is that VB does this automatically, where as C# doesn't.

The easiest way to test this is to create a Page_Init method, and put a break point in it.

Then, try flipping the AutoEventWireup , in C# it will only fire when true,
but in VB it fires in either event. VB handles this for you."

My reply was :

"Your explanation tells me what happens, but I already knew that.

Why is there a difference in the way the 2 languages handle that ?

This is confusing to users.

I think this is the first instance I see of a glaringly different way
the 2 main VS.NET languages handle a .Net configuration.

Syntax differences I understand.

Why one .Net language would treat a .Net application's settings in a
different way than another .Net language is a bit more difficult to understand."

So, now I ask all of you :

Why is the default for AutoEventWireup different for C# and VB.NET ?
Why does C# need AutoEventWireup set to "true" while VB.NET can make do with "false" ?

There used to be ( pre v2 ) a difference in the way websites written in VS.NET
handled event wiring, because VS.NET handled the event wiring for you,
while hand-written code needed auto event wiring, but this is the first time
I see that two .Net languages need different settings to handle a .Net application.

Juan T. Llibre
ASP.NET MVP
============



Dec 15 '05 #6

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

Similar topics

4
1649
by: Charts | last post by:
6/23/05 ..NET Development\Framework\dotnet.framework.aspnet Visual Studio 2005 Beta 2 project cannot work in IIS virtual directory I used Visual Studio 2005 Beta 2 to build a simple new web site. Default.aspx file is like following.
4
1329
by: Brent White | last post by:
The aspx file was originally default.aspx, but I'm putting some other aspx files in that same virtual directory and I want to give it a more meaningful name. I renamed default.aspx in the IDE to CorporateSelectStates.aspx, and the file default.aspx.vb was renamed to CorporateSelectStates.aspx.vb. Now when I try to build, I get an error saying "The file /CrystalReportsWebApplication1/Default.aspx.vb does not exist" It refers to line 1...
7
1561
by: Danny Tuppeny | last post by:
Hi all, Looks like autoEventWireup defaults to true in 2.0. Kinda silly if you ask me, since the MS site says there's a performance penalty, and I can't imagine it's something used very often! Anyway, anyone know where to change this setting? I've set the "default" in web.config to false, but new pages still have it coded into the page directive as true, which overrides. I don't want to have to do a search/replace before I publish the...
3
1223
by: Hardy Wang | last post by:
Hi all, I just installed VS.Net 2005 and tried to play with it. I have following questions 1) I created a web project, I compile it, unlike VS.Net 2003 but I could not find any DLL files in BIN folder, where are they? 2) I published the site, then I found a file named App_Web_xozrid3w.dll in folder where I published. It seems that this should be the compiled web project. BUT I could not find a setting how to control the naming of the...
3
1027
by: Shawn B. | last post by:
Greetings, We have a very large web application (300+ pages) (insurance software) that was ported from ASP.NET 1.1 to 2.0 via the Web Application Project add-in. There are some pages that the postbacks inexplicably don't function as intended. What happens is the postbacks do one of two things: 1) they act like a redirect and request the same page losing the query string parameters and the IsPostBack registers as false or 2) the attempt...
1
2902
by: cnixuser | last post by:
Hello, I am having a problem that I believe is related to the way a stream reader object looks for a text file by default. What I am doing is using a StreamReader object to read the text of a text file which includes some html code to populate html formatted content as the text of an asp:label (<asp:label>). The reading of the text file itself goes just fine ;however, this only occurs when I use an absolute file path which will not work of...
0
9767
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,...
0
11082
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, 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...
1
10807
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7939
isladogs
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...
0
5774
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...
0
5967
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4592
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
2
4190
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3215
bsmnconsultancy
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...

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.