473,289 Members | 1,810 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,289 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 1535
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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.