473,396 Members | 2,036 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,396 software developers and data experts.

VS 2005..Attaching event handlers

Hello All,

In VS 2003, I was able to add event handlers in the
InitializeComponent function. In VS 2005, I can no longer see the auto-
generated code.

I tried to add the event handler for a button in the Page_Load event,
bit this did not work.

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.SaveBtn.Click += new
EventHandler(this.SaveChanges);
}
}

Could somebody explain why the event handler doesn't register properly
when added in Page_Load event and what the correct procedure is for
adding event handlers in VS 2005 and if there is a way to view the
auto-generated code in VS 2005 ?
Thanks in advance!

May 21 '07 #1
2 1558
in vs2005, the form and the code behind are partial classes that are
compiled into one class, instead of using class inheritance. because of
this vs2005 no longer needs the hack of registering its event handles.
event handlers specified in the codebehind, can be accessed from the
form specifiation.

if you want to do your own hookup, it should be done in oninit.

-- bruce (sqlwork.com)
hharry wrote:
Hello All,

In VS 2003, I was able to add event handlers in the
InitializeComponent function. In VS 2005, I can no longer see the auto-
generated code.

I tried to add the event handler for a button in the Page_Load event,
bit this did not work.

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.SaveBtn.Click += new
EventHandler(this.SaveChanges);
}
}

Could somebody explain why the event handler doesn't register properly
when added in Page_Load event and what the correct procedure is for
adding event handlers in VS 2005 and if there is a way to view the
auto-generated code in VS 2005 ?
Thanks in advance!
May 21 '07 #2
also i noticed you don't add the event on postback, which is the only
time it would occur.

-- bruce (sqlwork.com)

bruce barker wrote:
in vs2005, the form and the code behind are partial classes that are
compiled into one class, instead of using class inheritance. because of
this vs2005 no longer needs the hack of registering its event handles.
event handlers specified in the codebehind, can be accessed from the
form specifiation.

if you want to do your own hookup, it should be done in oninit.

-- bruce (sqlwork.com)
hharry wrote:
>Hello All,

In VS 2003, I was able to add event handlers in the
InitializeComponent function. In VS 2005, I can no longer see the auto-
generated code.

I tried to add the event handler for a button in the Page_Load event,
bit this did not work.

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
this.SaveBtn.Click += new
EventHandler(this.SaveChanges);
}
}

Could somebody explain why the event handler doesn't register properly
when added in Page_Load event and what the correct procedure is for
adding event handlers in VS 2005 and if there is a way to view the
auto-generated code in VS 2005 ?
Thanks in advance!
May 21 '07 #3

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

Similar topics

13
by: Charles Law | last post by:
Mr "yEaH rIgHt" posted the following link about a week ago in answer to my question about removing event handlers. > http://www.vbinfozine.com/t_bindevt.shtml Following on from that post, the...
7
by: Michael D. Ober | last post by:
Is there anyway to raise an event from a class and require that any program using that class (not just inheritance) have an event handler for specific events in the class? In my case, some events...
5
by: Juan T. Llibre | last post by:
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...
2
by: Mark | last post by:
Hi everyone, I am having a tinker around with Visual Studio Professional 2005 and I am building a simple website: Now, in 1.1 the event handlers were declared in the code behind page and you...
3
by: Dino Buljubasic | last post by:
Hi, I am thinking of using visual inheritance. I am using C# VS 2005. I am concerned about how good it is. I have heard about problems like controls dissapearing or so. Any hints, tips,...
16
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some...
5
by: =?Utf-8?B?U2NhbmJveQ==?= | last post by:
Guyz, Whatever happened to the 'Index' property for a control, that used to be present in VB 3.0 / 4.0 / 5.0 / 6.0 and which now seems to be missing from VBE 2005? I need to be able to make 4...
5
by: gnassar | last post by:
Essentially my problem is that .NET 2005 is removing my event handlers. There's no real special things about my project, it just continually removes them all. It starts on the open of a...
5
by: debrief | last post by:
Hello, I have been trying to hide objects on the onclick event and it works fine in Firefox however IE does not respond at all. Is there a way around this? I have the following in my...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.