Thread: C# and JavaScript, how can I get Javascript to use a C# object?

  1. #1
    Registered User
    Join Date
    Sep 2008
    Posts
    47

    Question C# and JavaScript, how can I get Javascript to use a C# object?

    Hi guys,

    ANyone know how I can do this? Basically I have a COM component (active x) running on the client's machine (I registered the .DLL of the component) and I need to make a client side java script call to one of the functions. Well the problem is, the function returns a Complex C# data type (A class) and I need to return this to a java script varaible the problem is, I have no idea how to do this. I can't simply use var lol = x.ScanFinger("","",""); because x is returning that compelx data type

    The C# function call returns this data type:
    Code:
       public class ScanRetVal
        {
            public bool retVal;
            public string bitmap;
            public string userName;
        }
    }
    the function looks like this:
    Code:
     public ScanRetVal ScanFinger(string siteTitle, string siteURL, string userName)
            {
                this.mode = 2;
                this.scanWindow = new Scan(siteTitle, siteURL, userName);
                this.retVal = new ScanRetVal();
    
                // virtual scanner
                VirtualScanner.getInstance().addScanListener(this);
    
                // show the window
                System.Windows.Forms.DialogResult result = this.scanWindow.ShowDialog();
    
                // did they click cancel?
                if (result == System.Windows.Forms.DialogResult.Cancel)
                {
                    this.retVal.retVal = false;
                }
                else
                {
                    this.retVal.retVal = true;
                }
    
                VirtualScanner.getInstance().RemoveListener(this);
                return this.retVal;
            }
    Can you think of a better way to approach this?
    Basically this is a finger print scanner for webpages....I was thinking hell we could just use asp.net and set the language to c# and just make calls to the COM component that way but if we use asp.net, that means the client would have to have an IIS sever running to understand the asp.net page. If I used javascript though they could simply have any type of server to undertand the .html file with javascript calls
    Last edited by mr_coffee; 03-04-2009 at 07:31 PM.

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Maybe this might help

  3. #3
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    I am a bit confused. But I think this is what you would want.

    If you just want some data to come back from javascript you can post using an XMLHttpRequest

    http://www.w3schools.com/XML/xml_http.asp

    You can then post out to a remote page and send data back.
    Woop?

Popular pages Recent additions subscribe to a feed