list of raised events

T

Tim Mulholland

Out of curiosity, is there a way, while debugging an ASP.NET application, to
see what events have been raised that caused a postback to occur?

For instance, if a user clicked a button and the page posted back, is there
a way to see that the Page_Load event and the Button_Click events are in the
event stack to be handled before the page is returned?

Just curious.

Tim
 
K

Kevin Spencer

Assuming that you have an Event Handler, the firing of the Event Handler
indicates which Control caused the PostBack. In other words, if you have 2
buttons on a Page, and an Event Handler for each, the Event Handler that
fires indicates which Control raised the Event.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

Tim Mulholland

I'm asking this more for instances where i do have an event handler for an
event, but the code isn't firing.
the page is posting back, but the event is not firing.
I've seen this twice in recent days (once in my post right before this about
the SortCommand, and once with the IE bug where it doesn't pass the button
event back when you hit enter on a textbox) and some way to see the events
that are supposed to be raised would be helpful.

If my events aren't being executed, but the page is posting back - how am i
to figure out whats going on?
 
K

Kevin Spencer

If you're using Visual Studio.Net, you can set breakpoints, and use Watches.
Otherwise, assuming you're doing the debugging, you should know which button
you clicked.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

Tim Mulholland

well i'm doing the debugging. i'm clicking the link, its posting back, but
the event i am _expecting_ to be caught and thus executing is not happening.
so now i want to know what IS happening.
There's gotta be an event causing it to postback, but i don't have a clue
what it is, because its not what i expect. (i've double and triple checked
the event handlers, they're all set right)
 
K

Kevin Spencer

What type of Control is this "link"? How is it added to the Page?
Dynamically, or hard-coded?

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

Tim Mulholland

In this case, its the link that's the header of a datagrid when you turn
"AllowSorting" on on the datagrid.
I'm catching the SortCommand event, but that's never being executed when i
click this link. (there's a thread right before this one about it, but no
one has responded)
 
K

Kevin Spencer

I need to know what kind of Control it is, and how you're referencing it in
your CodeBehind.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
T

Tim Mulholland

Its not a control that i create.

Its in a DataGrid. I turn on AllowSorting, and this makes all of the headers
for the columns into what appear like LinkButton controls (though i don't
actually create them or have a reference to them).

I have the following line of code in my InitializeComponent() function
(auto-genned by VS):

this.dgNotes.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgNotes_SortC
ommand);

I then have a breakpoint in my dgNotes_SortCommand function. I never hit
that breakpoint when i click on the Sort link for any column in the
datagrid.

It postsback, but it does not go into the dgNotes_SortCommand function (or
any other function that i have written for that matter)
 
K

Kevin Spencer

I understand now. It sounds like you've done everything correctly. As I'm
not a big DataGrid user, I can't help much more at this point. I can offer a
suggestion, if nobody who is a DataGrid expert chimes in here (please do!).
You could try looking at the HTML generated on the client. PostBack events
are caused by JavaScript on the client, which sets the values of 2 hidden
form fields (__EVENTTARGET and __EVENTARGUMENT), and then submits the form.
See what the JavaScript is putting into those fields. Other than that, I'm
at a loss.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.
 
S

Steven Cheng[MSFT]

Hi Tim,

I've mentioned that you've posted two threads on the same problem on the
datagrid's sortcommand no fire. I've replied you in the former two ones.
Also, I'll repaste my reply here:
------------------------------------------------------------------------
Hi Tim,

From the you description, you used a webform datagrid(with allowSorting as
true) and you generate some columns which need sorting at runtime into the
datagrid. However, you found that at runtime, when clicking the sorting
link, the page was posted back ,but the datagrid's sort event wasn't be
fired, yes?

As for this problem, I doubt that whether it is caused by the event handler
not being registerd correctly. Do you register the
datagrid 's sortcommand handler statically or dynamically at runtime? For
example:

this.dgFire.SortCommand += new
System.Web.UI.WebControls.DataGridSortCommandEventHandler(this.dgFire_SortCo
mmand);

If you add the event handler at runtime ( in page init or page_load), do
you add it every time the page is loaded( not only firsttime)? If not , the
event handler will be lost when the page is posted back. In other words,
the page will still be posted back when clicking the sort link, but the
serverside's handler will never be hited.
I've attached a test page to show the behavior I mentioned above in this
message, please refer to it to see whether this is the cause of your
problem.

In addition, if the problem is caused by anything else, would you please
provide some further code on your page so that I can help to do some
further research on my side? Thanks.

----------------------------------------------------------------------------
------------------------

In addition, I think Kevin's suggestion that check the form fields
(__EVENTTARGET and __EVENTARGUMENT) is quite reasonable, besides check them
at clientside through html source, you can also check them at serverside
when using F5 debug(checking the request's form collection).

If you have anything unclear or have any further questions, please feel
free to post here or in the former thread.



Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
T

Tim Mulholland

I've replied to your response in my other thread and used the suggestions
from you and Kevin in my analysis for that answer.
Thanks for your help,

Tim
 
R

Ravichandran J.V.

Enable Trace for the page with the @Page directive or alternately, write
to the page using Trace.Warn/Write in the specific events with different
messages.

with regards,


J.V.Ravichandran
- http://www.geocities.com/
jvravichandran
- http://www.411asp.net/func/search?
qry=Ravichandran+J.V.&cob=aspnetpro
- http://www.southasianoutlook.com
- http://www.MSDNAA.Net
- http://www.csharphelp.com
- http://www.poetry.com/Publications/
display.asp?ID=P3966388&BN=999&PN=2
- Or, just search on "J.V.Ravichandran"
at http://www.Google.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top