473,473 Members | 1,874 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

C# Event Code

AG
Using VS 2005.

Usually I work in VB.NET.
In code behind when I need to add code to an event, I just select the object
in the upper left dropdown of the code window and then the desired event in
the upper right dropdown and the IDE builds the sub.

I am currently working on a project where the code behind is in C# and the
above functionality is not available.
Consequently, I find myself searching the web for the corrent arguments,
etc. for various control and page events.
The help files show few or none.

E.G.
protected void FormView1_ItemInserting(object sender,
FormViewInsertEventArgs e)
{
}

There must be an easier way to get this.
Can anyone advise or provide a link where one can find the format,
parameters, etc. for control events.
--

AG
Email: discuss at adhdata dot com


Feb 19 '07 #1
9 2802
Hello AG,

As for the C# development IDE, it does be a bit different from the VB.NET
IDE since they'are all customized according to the programming preference
of developers(or the language characteristics).

When you wang to register and event handler for an ASP.NET web control in
codebehind through Visual C# IDE, you can follow the following steps:

1. Switch to design view of the page, and select the certain control

2. Keep the control selected and go to the "properties window"

3. In the properties window, click the event tab(with a lighting icon),
then you'll see all the available events of the control

4. double click the certain event in the list to add a event handler in
codebehind(or you can select and existing handler functino from the
dropdownlist)

Here is the MSDN reference which detailedly describe this:

#How to: Create Event Handlers in ASP.NET Web Pages (Visual Studio)
http://msdn2.microsoft.com/en-gb/lib...2s(VS.80).aspx

BTW, for page events, the above rule doesn't apply. You need to directly
add the "Page_XXXX" handler function in codebehind (such as Page_Load,
Page_PreRender) and the runtime compiler will automatically wire it up.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Feb 19 '07 #2
AG
Thanks Steven,

That is exactly what I needed. Don't know why I did not see that lightning
bolt. For that matter I don't know why it is not easy to find that info
using Help.
Do you have a link that shows all the correct parameters for the various
page events?

--

AG
Email: discuss at adhdata dot com

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:eO*************@TK2MSFTNGHUB02.phx.gbl...
Hello AG,

As for the C# development IDE, it does be a bit different from the VB.NET
IDE since they'are all customized according to the programming preference
of developers(or the language characteristics).

When you wang to register and event handler for an ASP.NET web control in
codebehind through Visual C# IDE, you can follow the following steps:

1. Switch to design view of the page, and select the certain control

2. Keep the control selected and go to the "properties window"

3. In the properties window, click the event tab(with a lighting icon),
then you'll see all the available events of the control

4. double click the certain event in the list to add a event handler in
codebehind(or you can select and existing handler functino from the
dropdownlist)

Here is the MSDN reference which detailedly describe this:

#How to: Create Event Handlers in ASP.NET Web Pages (Visual Studio)
http://msdn2.microsoft.com/en-gb/lib...2s(VS.80).aspx

BTW, for page events, the above rule doesn't apply. You need to directly
add the "Page_XXXX" handler function in codebehind (such as Page_Load,
Page_PreRender) and the runtime compiler will automatically wire it up.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.


Feb 19 '07 #3
Thanks for your reply AG,

Sure, you can first search the Page class in MSDN and locate all its events:

#Page Events
http://msdn2.microsoft.com/en-us/library/2xz770y8.aspx

On the above page, you can click into each individual event and check their
eventhandler type. And the eventhandler type should contains the correct
signature. You can use your local MSDN since that'll be much quicker.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Feb 19 '07 #4
I have been learning ASP.NET over the last few months and this exact same
issue drove me copmletely crazy. I never saw that lightning bolt. Thanks!!!

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:eO*************@TK2MSFTNGHUB02.phx.gbl...
Hello AG,

As for the C# development IDE, it does be a bit different from the VB.NET
IDE since they'are all customized according to the programming preference
of developers(or the language characteristics).

When you wang to register and event handler for an ASP.NET web control in
codebehind through Visual C# IDE, you can follow the following steps:

1. Switch to design view of the page, and select the certain control

2. Keep the control selected and go to the "properties window"

3. In the properties window, click the event tab(with a lighting icon),
then you'll see all the available events of the control

4. double click the certain event in the list to add a event handler in
codebehind(or you can select and existing handler functino from the
dropdownlist)

Here is the MSDN reference which detailedly describe this:

#How to: Create Event Handlers in ASP.NET Web Pages (Visual Studio)
http://msdn2.microsoft.com/en-gb/lib...2s(VS.80).aspx

BTW, for page events, the above rule doesn't apply. You need to directly
add the "Page_XXXX" handler function in codebehind (such as Page_Load,
Page_PreRender) and the runtime compiler will automatically wire it up.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================

This posting is provided "AS IS" with no warranties, and confers no
rights.


Feb 19 '07 #5
AG
The keyword here is 'should'.
I followed the link and yes, it is the same content as my local MSDN, but I
don't see any signatures.

When I click on Load, I would expect to see something like
protected void Page_Load(object sender, EventArgs e)

Instead I get

public event EventHandler Load
and an example of

// This is the constructor for a custom Page class.
// When this constructor is called, it associates the Control.Load event,
// which the Page class inherits from the Control class, with the Page_Load
// event handler for this version of the page.
public MyPage()
{
Load += new EventHandler(Page_Load);
}

Not very useful for purposes of this discussion.
--

AG
Email: discuss at adhdata dot com

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:2P**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,

Sure, you can first search the Page class in MSDN and locate all its
events:

#Page Events
http://msdn2.microsoft.com/en-us/library/2xz770y8.aspx

On the above page, you can click into each individual event and check
their
eventhandler type. And the eventhandler type should contains the correct
signature. You can use your local MSDN since that'll be much quicker.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.


Feb 20 '07 #6
Thanks for your reply AG,

I've got your actual concern here. Yes, as you noticed, there hasn't an
existing list of all the page events' declare syntax such as:

Page_Load.....
Page_PreRender....

Actually, so far what we have are the following document:

**all the page events' name (this determine the event handler function's
name)

**all the page events' handler type(this determine the event handler
function's parameter/return type signature).

For example, when you want to add event handler for asp.net page in C#
codebehind, you first get its event name, suppose it is "PreRender", then
it is determined that the event handler function's name should be
"Page_PreRender". After that, you also get event's handler type, it is of
"EventHandler" delegate type(from the msdn reference I refered in previous
reply), so you further determine that you need to author the event handler
functiton as below:

void Page_PreRender(object sender, EventArgs e)
{

}

this is the same for other page events e.g.

void Page_PreInit(object sender, EventArgs e){...}
void Page_Init(object sender, EventArgs e){...}
void Page_Load(object sender, EventArgs e){...}
..............
BTW, the above function declare is used when you are set
AutoEventWireup=True for your page, in such case, ASP.NET runtime compiler
will automatically associate those handler funcion(with the
"Page_eventname" naming convention) to the correct Page event. If
"AutoEventWireup" is turn off, you need to explicily register event
handler, such as the following means you mentioned:

public MyPage()
{
Load += new EventHandler(Page_Load);
}

Here is another MSDN reference covers some non-IDE related info about
dealing with event handling of ASP.NET web controls and page:

#ASP.NET Web Server Control Event Model
http://msdn2.microsoft.com/en-us/library/y3bwdsh3.aspx

In addition, I think your feedback on the event documentation is really
reasonable and I recommend you add comments on the MSDN reference page
directly or send feedback to our product center:

http://connect.microsoft.com/feedbac...spx?SiteID=210

Hope this helps some further. If there is anything else we can help, please
feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 20 '07 #7
AG
Thanks Steven,

I think you made my point. Help is of little help!
It would be easier for me and developers like me to simply create a page in
a VB project, get all the page events, convert to C# and add to code
sniplets.

--

AG
Email: discuss at adhdata dot com

"Steven Cheng[MSFT]" <st*****@online.microsoft.comwrote in message
news:MC**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply AG,

I've got your actual concern here. Yes, as you noticed, there hasn't an
existing list of all the page events' declare syntax such as:

Page_Load.....
Page_PreRender....

Actually, so far what we have are the following document:

**all the page events' name (this determine the event handler function's
name)

**all the page events' handler type(this determine the event handler
function's parameter/return type signature).

For example, when you want to add event handler for asp.net page in C#
codebehind, you first get its event name, suppose it is "PreRender", then
it is determined that the event handler function's name should be
"Page_PreRender". After that, you also get event's handler type, it is of
"EventHandler" delegate type(from the msdn reference I refered in previous
reply), so you further determine that you need to author the event handler
functiton as below:

void Page_PreRender(object sender, EventArgs e)
{

}

this is the same for other page events e.g.

void Page_PreInit(object sender, EventArgs e){...}
void Page_Init(object sender, EventArgs e){...}
void Page_Load(object sender, EventArgs e){...}
.............
BTW, the above function declare is used when you are set
AutoEventWireup=True for your page, in such case, ASP.NET runtime
compiler
will automatically associate those handler funcion(with the
"Page_eventname" naming convention) to the correct Page event. If
"AutoEventWireup" is turn off, you need to explicily register event
handler, such as the following means you mentioned:

public MyPage()
{
Load += new EventHandler(Page_Load);
}

Here is another MSDN reference covers some non-IDE related info about
dealing with event handling of ASP.NET web controls and page:

#ASP.NET Web Server Control Event Model
http://msdn2.microsoft.com/en-us/library/y3bwdsh3.aspx

In addition, I think your feedback on the event documentation is really
reasonable and I recommend you add comments on the MSDN reference page
directly or send feedback to our product center:

http://connect.microsoft.com/feedbac...spx?SiteID=210

Hope this helps some further. If there is anything else we can help,
please
feel free to let me know.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no
rights.

Feb 20 '07 #8
Thanks for the followup.

Yes, code convertion between different languages does be a common problem.
As far as I know, the product team may want to leave more space for some
other 3rd party ISV or community on this. Anyway, it is also really welcome
to get such feedback from customers.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.

Feb 21 '07 #9
On Mon, 19 Feb 2007 22:20:23 -0500, "AG"
<NO**********@newsgroups.nospamwrote:
>The keyword here is 'should'.
I followed the link and yes, it is the same content as my local MSDN, but I
don't see any signatures.
I might highlight the fact that the operative word 'should' be
underlined.

After nearly 30 years of development I find the current help system
(especially the offline side of things) to be probably the worst that
I have ever used and not at all condusive for new (or even old)
developers.

Now there is so much clutter on the help pages, links are all over the
place and often you have to scroll down well past the end of the page
to find the basic overview links.

Gone are the days when one could jus hit F1 on a keyword, have the
help come up with what the keyword is does (in relation to its class)
and have some examples.

Now I have to have a degree in obfustication just to get past the "How
do I" rubbish or the "index" filters that seem to be heavily dyslexic.
Not only that, but if I hit f1 on a mehod name, I get an error stating
it cant find any help because it didnt understand what the instance
name is. I wonder who the person was that came up with the idea to
allow a help system to search on instance names (variable names).

ps. 90% of my development/work is done - not connected to the
internet (including using Office programs) and the like. So its
really annoying when help systems assume one has access to it.

----------------
AndyW,
Mercenary Software Developer
Feb 21 '07 #10

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

Similar topics

18
by: Christopher W. Douglas | last post by:
I am writing a VB.NET application in Visual Studio 2003. I have written a method that handles several events, such as closing a form and changing the visible status of a form. I have some code...
6
by: vbMark | last post by:
If I have a control, for example a CheckedListBox, how do I add and event to code, for example that a box has been checked by the user? Thanks
3
by: R Millman | last post by:
under ASP.NET, single stepping in debug mode appears not to stop within event procedures. i.e. 1) Create web page with submit button and event procedure for the click event in the code behind...
7
by: Charles Law | last post by:
I may have asked this before, but what is the purpose of both these functions? Is there a time when one should be called over the other? Does one supersede the other, or do they both have their...
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...
41
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based...
9
by: jeff | last post by:
New VB user...developer... Situation...simplified... - I want to wrap a pre and post event around a system generated where the pre-event will always execute before the system event and the...
3
by: geskerrett | last post by:
We have been asked to develop and application for a client that is a 'notification" system. We would like to use python, but are struggling to find the right starting point. Any suggestions, tips...
19
by: Daniela Roman | last post by:
Hello, I try to fire an event under a button click event and maybe anybody can give a clue please. I have let's say a WEB grid with PageIndexChanged event: private void...
4
by: tshad | last post by:
I am just getting started with events and had a couple of questions on why they do what they do. If you have a textbox and you want to handle an event you can just do: ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.