473,394 Members | 1,302 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,394 software developers and data experts.

Questions about "Handles BlahBlahBlah" for codebehind

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 codebehind by follwing some examples on the
Web and they work just fine.

However, I am scared away from codebehind by such extenstions as
"Handles MyBase.Load", "Handles Button1.Click" and "Handles
MyBase.Init" etc. which we seem to have to add to the signatures of the
Subs or Functions we define.

So, here are my questions:

1. When do we need to add such "Handles BlahBlah" extenstions?

2. Which "Handles XXX" do we add to what kind Subs? What are the
criteria?

Thanks.

May 18 '06 #1
6 1540
It makes no difference whether it's in the CodeBehind or not. It's all just
one class definition. The "Handles" statements indicate that the Sub is an
Event Handler. It handles an event fired by a Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
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 codebehind by follwing some examples on the
Web and they work just fine.

However, I am scared away from codebehind by such extenstions as
"Handles MyBase.Load", "Handles Button1.Click" and "Handles
MyBase.Init" etc. which we seem to have to add to the signatures of the
Subs or Functions we define.

So, here are my questions:

1. When do we need to add such "Handles BlahBlah" extenstions?

2. Which "Handles XXX" do we add to what kind Subs? What are the
criteria?

Thanks.

May 18 '06 #2
Codebehind or not does seem to have a difference. I never use "Handle
BlahBlah" in my inline aspx pages. But it seems that I must explicitly
say "Handle BlahBlah" in codebehind to handle button clicks for
example. Otherwise, it's not gonna work.

Kevin Spencer wrote:
It makes no difference whether it's in the CodeBehind or not. It's all just
one class definition. The "Handles" statements indicate that the Sub is an
Event Handler. It handles an event fired by a Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
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 codebehind by follwing some examples on the
Web and they work just fine.

However, I am scared away from codebehind by such extenstions as
"Handles MyBase.Load", "Handles Button1.Click" and "Handles
MyBase.Init" etc. which we seem to have to add to the signatures of the
Subs or Functions we define.

So, here are my questions:

1. When do we need to add such "Handles BlahBlah" extenstions?

2. Which "Handles XXX" do we add to what kind Subs? What are the
criteria?

Thanks.


May 18 '06 #3
Okay, since you know better than me, I'd better just shut up and listen.

--

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
Codebehind or not does seem to have a difference. I never use "Handle
BlahBlah" in my inline aspx pages. But it seems that I must explicitly
say "Handle BlahBlah" in codebehind to handle button clicks for
example. Otherwise, it's not gonna work.

Kevin Spencer wrote:
It makes no difference whether it's in the CodeBehind or not. It's all
just
one class definition. The "Handles" statements indicate that the Sub is
an
Event Handler. It handles an event fired by a Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
> 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 codebehind by follwing some examples on the
> Web and they work just fine.
>
> However, I am scared away from codebehind by such extenstions as
> "Handles MyBase.Load", "Handles Button1.Click" and "Handles
> MyBase.Init" etc. which we seem to have to add to the signatures of the
> Subs or Functions we define.
>
> So, here are my questions:
>
> 1. When do we need to add such "Handles BlahBlah" extenstions?
>
> 2. Which "Handles XXX" do we add to what kind Subs? What are the
> criteria?
>
> Thanks.
>

May 18 '06 #4
That's fine, since you do not want to help anyway.

Kevin Spencer wrote:
Okay, since you know better than me, I'd better just shut up and listen.

--

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
Codebehind or not does seem to have a difference. I never use "Handle
BlahBlah" in my inline aspx pages. But it seems that I must explicitly
say "Handle BlahBlah" in codebehind to handle button clicks for
example. Otherwise, it's not gonna work.

Kevin Spencer wrote:
It makes no difference whether it's in the CodeBehind or not. It's all
just
one class definition. The "Handles" statements indicate that the Sub is
an
Event Handler. It handles an event fired by a Control.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11**********************@g10g2000cwb.googlegr oups.com...
> 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 codebehind by follwing some examples on the
> Web and they work just fine.
>
> However, I am scared away from codebehind by such extenstions as
> "Handles MyBase.Load", "Handles Button1.Click" and "Handles
> MyBase.Init" etc. which we seem to have to add to the signatures of the
> Subs or Functions we define.
>
> So, here are my questions:
>
> 1. When do we need to add such "Handles BlahBlah" extenstions?
>
> 2. Which "Handles XXX" do we add to what kind Subs? What are the
> criteria?
>
> Thanks.
>


May 18 '06 #5
re:
That's fine, since you do not want to help anyway.
Please, let's limit our comments to technical issues.

re: But it seems that I must explicitly say "Handle BlahBlah" in codebehind
to handle button clicks for example. Otherwise, it's not gonna work.
Not necessarily.

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="button1_click"), 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.

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

You may set AutoEventWireup="true" for VB.Net.

In VS.Net 200x, this means that you can skip the "Handles ...." statement,
provided the method is named correctly.

E.g., if you have AutoEventWireup set to true, this method in a Codebehind file would handle the
Click Event of the Button Control with ID "Button1" without using onclick="Button1_Click"
declaratively :

Sub Button1_Click(ByVal s As Object, ByVal e As EventArg)
' Look, no Handles
End Sub

If you set AutoEventWireup="false", you would need to add the Handles:

Sub Button1_Click(ByVal s As Object, ByVal e As EventArg) Handles Me.Button1.Click
' Need Handles
End Sub

I hope this makes the issue a bit clearer for you.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<an***********@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com... That's fine, since you do not want to help anyway.

Kevin Spencer wrote:
Okay, since you know better than me, I'd better just shut up and listen.

--

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
> Codebehind or not does seem to have a difference. I never use "Handle
> BlahBlah" in my inline aspx pages. But it seems that I must explicitly
> say "Handle BlahBlah" in codebehind to handle button clicks for
> example. Otherwise, it's not gonna work.
>
> Kevin Spencer wrote:
>> It makes no difference whether it's in the CodeBehind or not. It's all
>> just
>> one class definition. The "Handles" statements indicate that the Sub is
>> an
>> Event Handler. It handles an event fired by a Control.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Complex things are made up of
>> lots of simple things.
>>
>> <an***********@yahoo.com> wrote in message
>> news:11**********************@g10g2000cwb.googlegr oups.com...
>> > 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 codebehind by follwing some examples on the
>> > Web and they work just fine.
>> >
>> > However, I am scared away from codebehind by such extenstions as
>> > "Handles MyBase.Load", "Handles Button1.Click" and "Handles
>> > MyBase.Init" etc. which we seem to have to add to the signatures of the
>> > Subs or Functions we define.
>> >
>> > So, here are my questions:
>> >
>> > 1. When do we need to add such "Handles BlahBlah" extenstions?
>> >
>> > 2. Which "Handles XXX" do we add to what kind Subs? What are the
>> > criteria?
>> >
>> > Thanks.
>> >
>

May 18 '06 #6
Hey, Juan, thanks a lot for your great education. I now know why I had
to say "handle blah blah". I thought that Kevin was grouchy for
something I said which I don't know, and I did not return to this group
for a while.

I've printed it out.

Thanks again.

Juan T. Llibre wrote:
re:
That's fine, since you do not want to help anyway.


Please, let's limit our comments to technical issues.

re:
But it seems that I must explicitly say "Handle BlahBlah" in codebehind
to handle button clicks for example. Otherwise, it's not gonna work.


Not necessarily.

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="button1_click"), 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.

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

You may set AutoEventWireup="true" for VB.Net.

In VS.Net 200x, this means that you can skip the "Handles ...." statement,
provided the method is named correctly.

E.g., if you have AutoEventWireup set to true, this method in a Codebehind file would handle the
Click Event of the Button Control with ID "Button1" without using onclick="Button1_Click"
declaratively :

Sub Button1_Click(ByVal s As Object, ByVal e As EventArg)
' Look, no Handles
End Sub

If you set AutoEventWireup="false", you would need to add the Handles:

Sub Button1_Click(ByVal s As Object, ByVal e As EventArg) Handles Me.Button1.Click
' Need Handles
End Sub

I hope this makes the issue a bit clearer for you.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
<an***********@yahoo.com> wrote in message
news:11**********************@i39g2000cwa.googlegr oups.com...
That's fine, since you do not want to help anyway.

Kevin Spencer wrote:
Okay, since you know better than me, I'd better just shut up and listen.

--

Kevin Spencer
Microsoft MVP
Professional Numbskull

Complex things are made up of
lots of simple things.

<an***********@yahoo.com> wrote in message
news:11*********************@j73g2000cwa.googlegro ups.com...
> Codebehind or not does seem to have a difference. I never use "Handle
> BlahBlah" in my inline aspx pages. But it seems that I must explicitly
> say "Handle BlahBlah" in codebehind to handle button clicks for
> example. Otherwise, it's not gonna work.
>
> Kevin Spencer wrote:
>> It makes no difference whether it's in the CodeBehind or not. It's all
>> just
>> one class definition. The "Handles" statements indicate that the Sub is
>> an
>> Event Handler. It handles an event fired by a Control.
>>
>> --
>> HTH,
>>
>> Kevin Spencer
>> Microsoft MVP
>> Professional Numbskull
>>
>> Complex things are made up of
>> lots of simple things.
>>
>> <an***********@yahoo.com> wrote in message
>> news:11**********************@g10g2000cwb.googlegr oups.com...
>> > 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 codebehind by follwing some examples on the
>> > Web and they work just fine.
>> >
>> > However, I am scared away from codebehind by such extenstions as
>> > "Handles MyBase.Load", "Handles Button1.Click" and "Handles
>> > MyBase.Init" etc. which we seem to have to add to the signatures of the
>> > Subs or Functions we define.
>> >
>> > So, here are my questions:
>> >
>> > 1. When do we need to add such "Handles BlahBlah" extenstions?
>> >
>> > 2. Which "Handles XXX" do we add to what kind Subs? What are the
>> > criteria?
>> >
>> > Thanks.
>> >
>


May 31 '06 #7

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

Similar topics

11
by: Rohit | last post by:
Hi, Threads in the .NET Framework 1.1 (and possibly in 1.0 also) leak "Event" handles, by Event handles I mean Win32 Event handles which can be monitored using the ProcessExplorer from...
1
by: Darren Wooding | last post by:
Hello, can anyone offer any advice, this one is driving me up the wall! 1. I am using a webform datagrid. 2. The columns are all dynamic and defined using templates (see code below). 3. I have...
12
by: johnb41 | last post by:
This question is regarding the "Handles" part of a routine, for example: Handles Button1.Click On Form2 (a User Control) I have a button. Here's it's code: Public Sub Button1_Click(ByVal...
7
by: Simon Verona | last post by:
I have a problem in my application which I believe is due to open handles.. . The symptom that users report is that after they have been using the application for a while, it will randomly just...
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"...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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
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
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...

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.