Click here to Skip to main content
15,913,486 members
Home / Discussions / C#
   

C#

 
AnswerRe: critical rigion Pin
Wes Aday3-May-12 6:13
professionalWes Aday3-May-12 6:13 
AnswerRe: critical rigion Pin
Bernhard Hiller3-May-12 21:23
Bernhard Hiller3-May-12 21:23 
AnswerRe: critical rigion Pin
Abhinav S3-May-12 22:00
Abhinav S3-May-12 22:00 
QuestionStreaming the response of type byte[] Pin
NarVish2-May-12 22:51
NarVish2-May-12 22:51 
QuestionRe: Streaming the response of type byte[] Pin
Richard MacCutchan2-May-12 22:53
mveRichard MacCutchan2-May-12 22:53 
AnswerRe: Streaming the response of type byte[] Pin
NarVish2-May-12 23:31
NarVish2-May-12 23:31 
GeneralRe: Streaming the response of type byte[] Pin
Richard MacCutchan3-May-12 0:10
mveRichard MacCutchan3-May-12 0:10 
GeneralRe: Streaming the response of type byte[] Pin
NarVish3-May-12 0:42
NarVish3-May-12 0:42 
GeneralRe: Streaming the response of type byte[] Pin
Richard MacCutchan3-May-12 0:54
mveRichard MacCutchan3-May-12 0:54 
GeneralRe: Streaming the response of type byte[] Pin
NarVish3-May-12 2:03
NarVish3-May-12 2:03 
QuestionEnter-PSSession : Connecting to remote server failed Pin
Sebastian T Xavier2-May-12 20:30
Sebastian T Xavier2-May-12 20:30 
AnswerRe: Enter-PSSession : Connecting to remote server failed Pin
Richard MacCutchan2-May-12 22:52
mveRichard MacCutchan2-May-12 22:52 
QuestionHow to get video stream from usb cam buffer Pin
bunyamin_2-May-12 4:45
bunyamin_2-May-12 4:45 
Questioncan't found provider sqlserver Pin
MemberDotNetting2-May-12 1:39
MemberDotNetting2-May-12 1:39 
AnswerRe: can't found provider sqlserver Pin
Wes Aday2-May-12 1:45
professionalWes Aday2-May-12 1:45 
GeneralRe: can't found provider sqlserver Pin
MemberDotNetting2-May-12 2:06
MemberDotNetting2-May-12 2:06 
AnswerRe: can't found provider sqlserver Pin
egenis2-May-12 2:03
egenis2-May-12 2:03 
Questionc# windows form & google api v3 Pin
mrx1002-May-12 0:39
mrx1002-May-12 0:39 
AnswerRe: c# windows form & google api v3 Pin
Richard MacCutchan2-May-12 2:42
mveRichard MacCutchan2-May-12 2:42 
GeneralRe: c# windows form & google api v3 Pin
mrx1002-May-12 4:38
mrx1002-May-12 4:38 
GeneralRe: c# windows form & google api v3 Pin
mrx1002-May-12 4:49
mrx1002-May-12 4:49 
AnswerRe: c# windows form & google api v3 Pin
loyal ginger2-May-12 9:21
loyal ginger2-May-12 9:21 
Your C# WinForm application with webbrowser control embedded in the form can use the following ways to achieve two-way communication between your C# code and the JavaScript code loaded by the webbrowser control.

From JavaScript to C#, follow these steps:

1. Create a member function in C#. In this example, suppose we have a function called "report_location":

C#
public void report_location(double latitude, double longitude)
{
    //you can do whatever you want to do in your C# function here
}

2. From your JavaScript code whenever you need to call the above C# function, do it like this:

JavaScript
window.external.report_location(...);

In the above function call the "..." represents the arguments you pass to the function. Use whatever arguments you need to use. For example if you are using Google Maps API and you add a listener to the map's click event, the function will be like this:

JavaScript
google.maps.event.addListener(
    map,
    'click',
    function(event){
        window.external.report_location(
            event.latLng.lat(),
            event.latLng.lng()
        );
    }
);

Your C# code will be able to get the clicked location's latitude/longitude.

From C# to JavaScript, follow these steps: (These will answer your specific question.)

1. In your JavaScript code create a function. In this example, suppose we have a function called "set_location":

JavaScript
function set_location(latitude, longitude){
    //this is your existing statement
    //var myLatlng = new google.maps.LatLng(30.050144, 31.240042);
    //this is the new statement
    var myLatlng = new google.maps.LatLng(latitude, longitude);
    //do whatever you want to do...
}

2. In your C# code whenever you need to call the above function to set the location, do it like this (suppose your webbrowser control is represented by the variable wb_map:

C#
wb_map.Document.InvokeScript(
    "set_location",
    new string[]{
        "30.050144",
        "31.240042"
    }
);

Of course if the numbers are stored in variables such as latitude, longitude, the above call will be

C#
wb_map.Document.InvokeScript(
    "set_location",
    new string[]{
        latitude.ToString(),
        longitude.ToString()
    }
);

Hope this answers your question. Happy programming!
GeneralRe: c# windows form & google api v3 Pin
mrx1003-May-12 7:39
mrx1003-May-12 7:39 
GeneralRe: c# windows form & google api v3 Pin
loyal ginger3-May-12 15:51
loyal ginger3-May-12 15:51 
GeneralRe: c# windows form & google api v3 Pin
mrx1004-May-12 1:32
mrx1004-May-12 1:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.