0

I've seen in quite a few examples of asp.net ajax client side script the following:

function fHelloWorld(source, eventArgs)
{

}

If I run an alert on the source it's returned as an object. Can I use this to access what called the function? And if so how? i've tried things like

source.id;

Without luck

2 Answers 2

1

The best advice that I can offer is, given an object, enumerate over the properties and write them out, including their values to the page. Then inspect the property values and will surely find out if such a property exists. You could also use Firebug, Fiddler2 or host of other tools to inspect the object.

Here's an example

function pageLoad(sender, args) {

// add function to the PageRequestManager to be executed on async postback initialize
var prm = Sys.WebForms.PageRequestManager.getInstance();
      prm.add_initializeRequest(InitializeRequest);   
}


function InitializeRequest(sender, args) {
    // Display loader gif when async postback initialized by element_in_question
    if(args._postBackElement.id === 'id_of_element_in_question' {              
        $get('ajax-loader').style.display = 'inline';
    }         
}
Sign up to request clarification or add additional context in comments.

Comments

0

Run the page with Firefox & Firebug, set a breakpoint inside your function, and inspect the source object interactively.

You can also display the object with console.log to get an object inspection hyperlink:

function fHelloWorld(source, eventArgs)
{
  console.log("%o", source);
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.