is there any object available in c#/asp.net which can give me event name in
that eevnt only. Like if I am in Page_load event, i should get Page_Load or
if I am in Button_click event I should get Button_Click. SO that I can logg
it in my cutom log file with a generic logic.
Thanks
Eliyahu Goldin - 19 Jul 2007 09:51 GMT
Look at the TraceEventCache.Callstack property and the StackTrace class.
From the MSDN:
The Callstack property gets the call stack from the StackTrace property of
the Environment class. The property value lists method calls in reverse
chronological order. That is, the most recent method call is described
first. One line of stack trace information is listed for each method call on
the stack. For more information, see StackTrace.

Signature
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
> is there any object available in c#/asp.net which can give me event name
> in
[quoted text clipped - 5 lines]
>
> Thanks
Manish Bafna - 19 Jul 2007 10:40 GMT
Hi,
If you're writing a tracing and logging component you may well want to pass
the current method name to your logging component. Rather than hard code it
(then forget to change it when you change the method name) you can use
reflection and the MethodBase class to retrieve the name.
System.Reflection.MethodBase currentMethod =
System.Reflection.MethodBase.GetCurrentMethod();
System.Diagnostics.Debug.WriteLine(currentMethod.Name);
System.Diagnostics.Debug.WriteLine(currentMethod.DeclaringType.Name);
System.Diagnostics.Debug.WriteLine(currentMethod.DeclaringType.Namespace);
ref:http://idunno.org/archive/2004/12/03/163.aspx

Signature
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.
> is there any object available in c#/asp.net which can give me event name in
> that eevnt only. Like if I am in Page_load event, i should get Page_Load or
> if I am in Button_click event I should get Button_Click. SO that I can logg
> it in my cutom log file with a generic logic.
>
> Thanks