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

  1. #1
    Registered User
    Join Date
    Sep 2008

    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:
       public class ScanRetVal
            public bool retVal;
            public string bitmap;
            public string userName;
    the function looks like this:
     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
                // 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;
                    this.retVal.retVal = true;
                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 and set the language to c# and just make calls to the COM component that way but if we use, that means the client would have to have an IIS sever running to understand the 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 06:31 PM.

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

  3. #3
    Join Date
    Aug 2002
    Tucson, Arizona
    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

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

Popular pages Recent additions subscribe to a feed