How to know method name dynamically with sender or EventArgs object

Hello All,
I am working in ASP.NET. I wanna log method name in log file whenever that method is executed. e.g.
protected void Page_Load(object sender, EventArgs e)
Trace.Log("Page_Load start");
Trace.Log("Page_Load end");
protected void Method2(object sender, EventArgs e)
Trace.Log("Method2 start");
Trace.Log("Method2 end");
Trace.Log() is use to log my string in log files at D:\. Now, here I have hard coded Method name in Trace.Log(). But, now I want to fetch method name via c# code. Can we achieve it via sender or EventArgs object?
Please assist.
Thanks, Chintan

Hello Chintan,
You can get class name through reflection as it gets STATIC info about the component.
However, to get the line number of an exception, which is a run time parameter, you cannot use reflection.
I actually have not tried this before but, given it did not work for you in the web part class, you may try the below code in your *.ascx.cs user control used by your visual web part.
//To Retrieve class name use this line:
string className = this.GetType().FullName;
// To retrieve other parameters including line number
try
TestFunction();
catch (Exception ex)
StackTrace st = new StackTrace(ex, true);
StackFrame[] frames = st.GetFrames();
// Iterate over the frames extracting the information you need
foreach (StackFrame frame in frames)
string stkFrame = string.Format("{0}:{1}({2},{3})", frame.GetFileName(), frame.GetMethod().Name, frame.GetFileLineNumber(), frame.GetFileColumnNumber());
For more info, please refer to this
post.
THosE wHo doN'T apPreCiATe LiFe, DOn't DeSerVe iT

Similar Messages

  • How to know the forms associated with a specific transaction

    Hi..
    Can anyone please suggest me how to know the forms associated with a specific transaction.
    For Example In Finance module.
    I came to know from SDN the form associated with F.64 as F140_acc_stat_01.
    But i need the steps how to track the form name.
    Regards..
    Vinodh

    Hi,
    1.We cann't find the forms associated with a specific transaction.
    2.But,based on requirement we can go for the form selection.
    3.Suppose in account payable and receivable , we have different forms like customer statement, Dunning and Chek form etc.
    4.The functional people can find the form name in SPRO and give the details of the requirement.
      5.If u have the output type or formname u can go for the TNAPR and  TTXFP tables and u can search for the respect object.
    6.For FI u can directly find in the SPRO, by searching it with the form name.
    Regards,
    If helpful reward with points(Don't forget).

  • How to know the PO  Created with RFQ or Not..??

    Hi MM Gurus,
    How to know the purchase order created with one quotation or not. because when i am trying to create PO with /ME21N through DOcumen Overview on. there is list of Quotation. i created PO with XYZ quotation. and after creation of PO i am trying to create another PO with another quotation but in that list still XYZ quotation is Displying. so how to knows once PO cretd with Quotation or not. . and I dont wanted to disply quotation once created Po.
    Thanks in Advance.
    N.A.Reddy

    Hi Pradeep. Thanks for the mail.
    the problem is ....with *quotation...*
    How to know the purchase order created with one quotation or not.
    because when i am trying to create PO with /ME21N through DOcumen Overview on. there is list of Quotation.
    I created PO with XYZ quotation. and after creation of PO i am trying to create another PO with another quotation but in that list still XYZ quotation is Displying.
    so how to knows once PO cretd with Quotation or not. .
    and I dont wanted to disply quotation once created Po.
    Thanks in Advance.
    N.A.Reddy

  • How to know Apple Id associated with that perticular device (Macbook Pro)?

    Hi experts there...!
    How to know Apple Id associated with that perticular device (Macbook Pro)?
    How to change the Apple Id associated with the particular device?
    Okay now the scene is that one of my friend gave me macbook pro as a gift, now we both dont know how to change the associated Apple Id with this Macbook pro. He has his apple id and password which works perfectly with this macbook. But we want to change associated apple id with this macbook. After changing the apple id will it be possible to update mountain lion or to reinstall online completly? Does this process completely disconect from previous apple id and connect with new apple id?

    Welcome to Apple Support Communities
    If your friend's Mac didn't come with DVDs, he has to call Apple in order to deauthorize his Apple ID from the Mac > http://support.apple.com/kb/HE57
    After that, you will be able to register the MacBook Pro with your Apple ID, and you will be able to install OS X, iPhoto, iMovie and GarageBand for free. After doing that, you can erase the hard drive and reinstall OS X, so everything from his Apple ID will be removed

  • HT3529 how do i set name groups to send sms messages

    how do i set name groups to send sms messages

    Go through these discussions.
    https://discussions.apple.com/message/18008223#18008223
    https://discussions.apple.com/message/11126197#11126197

  • How to fix the .pdf file with error "invalid annotation object"

    how to fix the .pdf file with error "invalid annotation object"

    As long as the PDF opens, then just try saving it to a new file name. There may be a preflight script that would help troubleshoot the issue.

  • SPD 2010 - How to know if a file with a given name already exists in a document library

    Hi,
    I've created a workflow using SPD. One of the steps in there is changing the name of the document to a clean name. This workflow fails if a document with this same name already exists in my document library. Is there a way to check in a SPD workflow if
    a document with a given name already exists in my document library ?
    Marc Nemegeer

    Hi,
    According to your post, my understanding is that you wanted to know if a file with a given name already exists in a document library.
    You can use a SharePoint Designer workflow to achive it.
    To test to see if a document exists, you need to use condition:
    If Current List:Name  equals  [%Current Item:Title%].docx
    Here is a similar thread for you to take a look at:
    http://social.technet.microsoft.com/Forums/en-US/cc227020-ce81-4c08-aee0-a66789d8ad05/test-to-see-if-document-exists?forum=sharepointcustomizationprev
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • How to generate file name dynamically in receiver FIle adapter? Please help

    Dear Experts,
       I have a scenario where I need to generate output file with the name dynamically pulled from the XI payload.
       In receiver File communication channel I don't see any option where we can specify the XML path for the file name.
       For example:
       If my inbound XML structure (inbound interface) is like below:
       <filename>file123.txt</filename>
       <RootNode>
             <Element1>Product123</Element1>
       <RootNode>
      From this I need to pick the filename value and generate the output file with the same value.
      How can I achieve this? Please help!
    Thanks & Regards
    Gopal
    Edited by: gopalkrishna baliga on May 3, 2011 1:10 PM

    Gopal,
    You can use DynamicConfiguration class for this.
    You need to write UDF for this and with input of filename you want to set and map this UDF to the top level node.
    Refer the below famous blog from Micheal:
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    You can also use Variable substitution to get value from payload, search SDN on this.
    --Divyesh Vasani

  • How to change the name associated with iCloud email alias??

    I had MobileMe on the iPhone with alias email addresses and I liked how it didn’t attach any “name” to an alias. For example, I had MainUserName, then for aliases I would have [email protected], [email protected], etc. When I sent an email from my iPhone using one of the aliases as the "from" no name would be associated with the alias email address. If it was the MainUserName then it would associate it, e.g. Main User <[email protected]> will show up on the "From" field when I sent an email. But with iCloud on the iPhone (and iPad), it’s Main User <[email protected]>, Main User <[email protected], etc., which I don’t want.  If anything it should be Alias 1 <[email protected]> or Alias 2 <[email protected]>.  Anyway, I don't want any name associated with the aliases, so when I send an email it will simply say [email protected] or just [email protected] with no name association. 
    It works differently if I access iCloud through a web browser.  If I send an email via iCloud on the web, I can customize and have a different name with each alias, e.g., Tom <[email protected]> or Harry <[email protected]>  And the customization carries over to the Mail app on my Mac.  That would be ideal if the customization carried over to the iPhone and iPad, but I'd be happy if there was no name association with alias email addresses.  Hopefully, there's a solution to the iPhone/iPad situation with iCloud as I don't want the name linked with the main iCloud email address linked with all the different email aliases I have.

    Can I change the name associated with an ipod on my Mac?
    Select the iPod in the iTunes source list, click on its name, and type a new name.
    And can there be more than one iPod on one computer?
    Yes.
    (39352)

  • How to know column name (not an expression) used by function-based index?

    Hi guys,
    Is there any way to know exact column name used by FBI? If I correct, there is SYS.ICOLDEP$ table that has mapping between index/table columns, but I don't see how it could be uniquely joined with the rest. I know about USER_IND_EXPRESSIONS, but the task is to know exact column name, not it's expression.
    This required by our so-called SQL preprocessing of DB schema update utility, which parses stmt (INSERT in our case) and should check against PK/UNIQUE key values.
    Thanks!

    I don't think this is possible in 10g or 11g because :
    1. dictionary keeps track of column number in index and not in table
    2. the expression used in CREATE INDEX is a system generated column
    You would have to parse the expression from USER_IND_EXPRESSIONS:
    SQL> create table t(x int, y int);
    Table created.
    SQL> create index fbi on t(y+1);
    Index created.
    SQL> column index_name format a10
    SQL> column column_name format a20
    SQL> column column_expression format a10
    SQL> select i.index_name, ic.column_name, ic.column_position as iccn, ie.column_position as iecn, ie.column_expression
      2  from user_indexes i , user_ind_columns ic, user_ind_expressions ie
      3  where i.index_name = ic.index_name
      4  and i.index_name = ie.index_name
      5  and i.index_name =  'FBI';
    INDEX_NAME COLUMN_NAME                ICCN       IECN COLUMN_EXP
    FBI        SYS_NC00003$                  1          1 "Y"+1

  • How to know file names & version on EBS 12.1.1

    Hi guys
    Please help I work with EBS 12..1.1 on HP-UX
    When apply patch no. 8429053 to support financial consultant ,I read the patch read me and as required I must know the file name and version as following .
    *3. Fixed File Names and versions*
    *$xla/patch/115/sql/xlaaptrn.pkb 120.63.12010000.14*
    and i found wrote *"cd $XLA"* then I didn't find it how to know this info
    Thanks

    Hi,
    It's not uncommon for the documentation to omit '_TOP' from the environment variable names, unfortunately. Try 'cd $XLA_TOP' instead.
    You can refer to Note 121916.1: How To Get Version of Programs, Files, and Objects Necessary for Oracle Applications? to find out how to get the version of the file you need.
    (Edit: Whoops, look like I left my browser tab open too long, and Srini already answered your question. :) )
    Regards,
    John P.
    http://only4left.jpiwowar.com
    Edited by: jpiwowar on Apr 24, 2010 8:17 AM

  • SSDT vs 2013 and Clr function, call a Clr method name dynamically using SQLCMD variables

    Hello,
    My question is this, hopefully this makes sense:
    How could I got about doing this, inside a SQL function, I would like to re-name the Clr method call based on a SQLCMD variable? 
    I have a Clr project to encrypt/decrypt data, there are different method names depending on the deployment types.
    For the definition of a function called dbo.EncryptThis, I would like to use a SQLCMD variable to change the name depending on SQLCMD variables. This works fine in SQL Server Mgmt studio, but VS 2013 fails to recognize the SQLCMD variable and the build fails
    with: "Error
    1
    SQL71521: A method with a matching signature was not found in the loaded assembly.".
    THis code works fine in SQL Server Mgmt Studio, but fails to build in the SSDT project.
    In the SSDT project I have the SQLCMD variable defined and think I have SQLCMD mode enabled, by doing this:
    Right click file > Execution Settings > SQLCMD mode
    CREATE FUNCTION [dbo].[EncryptData]
    (@str NVARCHAR (MAX))
    RETURNS NVARCHAR (MAX)
    AS
    EXTERNAL NAME [CryptoClrAssembly].[LibName].[EncryptData$(MethodName)]
    Is this even possible in SSDT? or would I have to do this in a post-deploy script?

    Hi Kevin,
    Thanks for the info.
    Bummer, so the only other solution I have is to create a post-deploy script to change the function based on a SQLCMD variable or other logic?
    What would be really cool, would be if during the build process the SQLCMD variables would get replaced with the default value to the SQLCMD variable, thus would allow to build the project. Also, during deployment, if someone entered an incorrect method
    from the assembly it would just fail.

  • How to determine method name at runtime

    hello,
    i try to get method name at runtime..i have a logger and i need this info for logger
    private void method(){
    myLogger.debug( "exception in " + getExecutedMethod() ); /* output should be: exception in method */
    }best regards
    cem

    bcem wrote:
    what i needed was
    [http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html|http://today.java.net/pub/a/today/2008/04/24/add-logging-at-class-load-time-with-instrumentation.html]
    regards
    cemYou could also use AOP to add logging. But really, any sort of injected logging is going to be of limited value, since it's very generic and "this method was called with these parameters"-esque. Explicit logging is a lot more descriptive and useful, particularly to support staff who probably won't know what any particular method does

  • How to know the name of a message catalog

    Hi ,
    is it possible to know the name of a message catalog at runtime
    (ie: 'myappli.cat' in place of qqlo_MessageCatalog) ????
    thanks.
    Cordialement.
    Patrice Bourdon
    Alliance Sante France
    Tel : (33) 02.54.60.26.27
    Fax : (33) 02.54.60.25.00
    e-mail: mailto:[email protected]
    web : http://www.alliance-sante.fr
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    You can use @@PROCID And Object_Name() to get that value, for example
    Create Function dbo.FooGetMyOwnName ()
    Returns sysname
    AS
    Begin
    Declare @MyName sysname;
    Set @MyName = Object_Name(@@PROCID);
    Return @MyName;
    End;
    go
    Select dbo.FooGetMyOwnName();
    go
    sp_rename 'dbo.FooGetMyOwnName', 'FooIChangedMyName';
    go
    Select dbo.FooIChangedMyName();
    go
    Drop Function dbo.FooIChangedMyName;
    Tom

  • HOW TO GIVE CLASS NAME DYNAMICALLY???

    Hi all!
    I want to give class name dynamically to my statment
    <jsp:useBean id="myBean" scope="session" class="myPackage.myClass"/>
    now here i want to pass a String as class name how can i do it?
    Jiaa:):):)

    Hi,
    You can't assign dynamically a classname in the instruction jsp:useBean
    S�b

Maybe you are looking for

  • How can i put image in a button?

    I need to put an image ( .bmp ) in a button, but i don't know how. I need it because in web forms the icons ( files .ico) no show. How can i solve this problem? Thanks!!

  • Digital Signature is shown as altered when nothing is modified

    Hi, I have a problem with the digital signature field. After signing the form and saving it, when I next open the form, there will be a icon (green tick + yellow !) indicating that the signature is valid but the document has been updated since signed

  • Add metadata (non-image data) to an image

    Hello, I want to read an image and add metadata (non-image data) like copyright... to the image and write it. I am able to read metadata of an image but couldn't add (write) into it... Help required urgently Regards Mamatha

  • Mapping measures of cube with data using awm

    hi i am new in using analytic workspace manager i have already created dimension of a cube and mapped data into that.the i created cube now i want to map dimension into cube and aggregating values into measures.but i am unable to load data into cube

  • How to manage oracle 8i db

    I have the next question: I am testing different databases. At the first time I install an oracle 8 standard database, then I becomes a lot of database management tools as Oracle enterprice manager. Now I have install the oracle 8i enterprice databas