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

declaritive or code behind eventhandler assignment?

Is it better to assign eventhandlers in codebehind:
this.Button1.Click += new EventHandler(Button1_Click);

or delcaritive:
<asp:button id="Button1" runat="server" onclick="Button1_Click"
text="Button" />

Or does it matter either way; and if so, why?. I've been doing it in
codebind, but I'm thinking about switching to declaritve.

Thanks
Jan 27 '06 #1
2 1083
Phil,
I doubt it makes much difference, since you are going to get/need an event
handler method in either case.
Whatever your individual coding style dictates.

Personally I prefer using the "Lighting bolt" events page of the Properties
window for a control, since I know the IDE won't make any typing boo-boos.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Phil" wrote:
Is it better to assign eventhandlers in codebehind:
this.Button1.Click += new EventHandler(Button1_Click);

or delcaritive:
<asp:button id="Button1" runat="server" onclick="Button1_Click"
text="Button" />

Or does it matter either way; and if so, why?. I've been doing it in
codebind, but I'm thinking about switching to declaritve.

Thanks

Jan 27 '06 #2
Thanks for the reply. That's what I was thinking about moving to, guess I'll
give it a try.

Thanks.

"Peter Bromberg [C# MVP]" wrote:
Phil,
I doubt it makes much difference, since you are going to get/need an event
handler method in either case.
Whatever your individual coding style dictates.

Personally I prefer using the "Lighting bolt" events page of the Properties
window for a control, since I know the IDE won't make any typing boo-boos.
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Phil" wrote:
Is it better to assign eventhandlers in codebehind:
this.Button1.Click += new EventHandler(Button1_Click);

or delcaritive:
<asp:button id="Button1" runat="server" onclick="Button1_Click"
text="Button" />

Or does it matter either way; and if so, why?. I've been doing it in
codebind, but I'm thinking about switching to declaritve.

Thanks

Jan 27 '06 #3

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

Similar topics

2
by: Andre | last post by:
I'm trying to add a asp.net page which will act as a contact-me e-mail form to keep our e-mail addresses hidden from page visitors. I've created a combo/drop down box listing our various...
1
by: | last post by:
Hi guys! I am a beginner with aspx (i have some background with .asp). And i am trying tu use a 'code-behind' page in order to execute all transactions in that page and leave as clean as possible...
4
by: Carlo Marchesoni | last post by:
I have a button that opens a new Window (some kind of search-window), which is fired using JavaScript (btnSearch.Attributes=".....";) Now I need to run some code behind code BEFORE this JavaScript...
4
by: sklett | last post by:
I'm fairly new to Threading and things have been going pretty smooth so far. I did some performance testing on my new app and realized it's lagging a bit on raising events. It's a realtime app and...
20
by: Mukesh | last post by:
Hi all, Consider this code SqlConnection oConn = new SqlConnection(AccountsConnectionString); SqlCommand cmdInsert = new SqlCommand("UpdateQuery"); //Location 1: //SqlTransaction sqlTran =...
1
by: Alan T | last post by:
private void MainForm_Load(object sender, EventArgs e) { tsHelpDropDownButton.MouseLeave += new EventHandler(this.MenuDropDownButton_MouseLeave); } private void...
8
by: gw7rib | last post by:
I've been bitten twice now by the same bug, and so I thought I would draw it to people's attention to try to save others the problems I've had. The bug arises when you copy code from a destructor...
1
by: Niron kag | last post by:
Hi, I am writing in .net 1.1 asp.net program in c#. In the code behind I declared a reference html control (frame): HtmlControl rightFrame = (HtmlControl)mainFrame.FindControl("frmRight"); ...
24
by: Grey Alien | last post by:
If I have the ff struct: struct A { unsigned int i; char s; } a, b; And use them in code like this:
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.