Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

where is a javascript object defined

Posted on 2012-03-22
12
Medium Priority
?
235 Views
Last Modified: 2012-03-23
I'm maintaining an application. In a javascript .js file, the code below, I'm tracing and trying to find what GetDetails does. But I cannot find where ObjName is defined in any javascript file. I found a class definiation with the same name ObjName defined in a .cs file. I'm confused. .cs file runs on server. Where can I find the place defines ObjName?

Thanks. I know it is a basic question.
 
function myfunction()
{
    if (document.getElementById(ddlDropdown).value != '') {
        document.getElementById(fld1).value = document.getElementById(ddlDropdown).value;
        ObjName.GetDetails(document.getElementById(fld1).value, DoSomething, Onfailure);
    }
}
0
Comment
Question by:minglelinch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 6
12 Comments
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37754293
use firebug to debug this script, i hope you are aware of it.
Anyways, here is a link to it...
http://www.evotech.net/blog/2007/06/introduction-to-firebug/

there must be a prototype with GetDetails Function in it.
If there is no such prototype, probably this is not the right code....
0
 
LVL 1

Author Comment

by:minglelinch
ID: 37754510
Yes, I found prototype while I'm debug it. I also find the GetDetails is a C# function of ObjName class in ObjName.cs file. This is my first time for the concept prototype in .net development. Is it a connect for javascript and web methord? web service? Could you please give more about it? Thank you.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37754561
prototypes are basically classes in Javascripts which are converted to objects.
This method should be in JS, how can you call a method in cs from within JS since JS is client side script and CS is server side.

Use Firebug to debug and see...
0
Tutorials alone can't teach real engineering

So we built better training tools.

-Hands-on Labs
-Instructor Mentoring
-Scenario-Based Tests
-Dedicated Cloud Servers

All at your fingertips. What are you waiting for?

 
LVL 1

Author Comment

by:minglelinch
ID: 37754657
Thank you a lot.

It's said Firebug works with Firefox. I'm using IE. At this time kind of wondering ...

Where or how to create protype?
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37754683
0
 
LVL 1

Author Comment

by:minglelinch
ID: 37754999
Nice link and thanks for your direction. Let me ask a further question please.

While I'm debuging to the above code, I was brought to jsdebug [dynamic] which contains the following code:

var ObjName=function() {
ObjName.initializeBase(this);
this._timeout = 0;
this._userContext = null;
this._succeeded = null;
this._failed = null;
}
ObjName.prototype={
_get_path:function() {
 var p = this.get_path();
 if (p) return p;
 else return Address._staticInstance.get_path();},
... ...
... ...

GetDetails:function(address,succeededCallback, failedCallback, userContext) {
/// <param name="address" type="String">System.String</param>
/// <param name="succeededCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="failedCallback" type="Function" optional="true" mayBeNull="true"></param>
/// <param name="userContext" optional="true" mayBeNull="true"></param>
return this._invoke(this._get_path(), 'GetDetails',false,{address:address},succeededCallback,failedCallback,userContext); },


It seems like the place where defines the prototype and the method. But it's like generated dynamically. No other places where I can find the method definition, which lead me think that the prototype is generated by some modul creation. But how is here?

Thanks.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37755815
these are the classes used by firebug to enable debugging.
This is where the debug symbols are loaded by, has got nothing to do with your code....
0
 
LVL 1

Author Comment

by:minglelinch
ID: 37757429
Thanks. I debug it again. ((ObjName is Address)
)

I set break point to
ObjName .GetDetails(document.getElementById(fld1).value, DoSomething, Onfailure);

then execution jump to
ObjName ._staticInstance.GetDetails(address,onSuccess,onFailed,userContext); }
then to
return this._invoke(this._get_path(), 'GetDetails',false,{address:address},succeededCallback,failedCallback,userContext);
then to
ObjName .prototype={
_get_path:function() {
 var p = this.get_path();
 if (p) return p;
 else return Address._staticInstance.get_path();},
then to
return Sys.Net.WebServiceProxy.invoke(d,e,g,f,c,b,a,this.get_timeout())
......
var b=new Sys.Net.WebRequest
... ...
var d=Sys.Net.WebRequest._createQueryString(b) ...

The javascript function is added by
ddlboxname.Attributes.Add("onchange", "myfunction();return false;");


Except GetDetails method in ObjName.cs, there's no GetDetails function in the whole project. GetDetails method in ObjName.cs does the expected work for onchange event, btu this is on the server side.

How does all this work?

I know it is a mess question. May it is the point where my problem is.

Thanks.
0
 
LVL 20

Expert Comment

by:BuggyCoder
ID: 37758558
i think you are using ajax control library and scriptmanager, updatepanel etc...
0
 
LVL 1

Author Comment

by:minglelinch
ID: 37758686
Thanks for answering. Yes, I do use those. Does it matter?
0
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 2000 total points
ID: 37758704
oh yes it does, there lies an answer to your question of how the server side method is bieng called in Js.

This is because it is a part of <asp:ScriptManager>
Read Here to see how it works:-
http://msdn.microsoft.com/en-us/magazine/cc163354.aspx
0
 
LVL 1

Author Closing Comment

by:minglelinch
ID: 37759321
Great answer, thank you.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question