0

I have a javascript function which I want to send to c#.

The c# function will then send that information to the fiscal printer.

The function will get elements id from html document.

The function looks like this

function senddata(price)
{
  priceElem=document.getElemById("price");
}

I want to send data to c# function which will be printing. I have a file that is created by .net which I want to include in my c# function.

This .dll file will connect to the fiscal printer and c# function. The .dll will help in communicating between the program and the fiscal printer. The html and javascript is retrieving this information in another program. I am using incotex fiscal printer. This c# program will be printing the receipt. Someone out there please help.

Regards, masiela

Iridio
  • 9,213
  • 4
  • 49
  • 71
  • Is this JavaScript running in a webbrowser? IE? Can you run in it the WebBrowser control? –  Apr 14 '12 at 09:13
  • See these: http://stackoverflow.com/questions/1905716/clientscript-registerclientscriptblock – Harold Sota Apr 14 '12 at 09:21
  • @Haroldis That's entirely different... it's just for ASP.NET reconstruction. In any case, I'm not sure why this is being closed as "not constructive". It could be worded better here, but it *does* seem like a real question for a specific task. (Consider how many "if statement not working" and "NPE" questions that *aren't* closed as they should be :-/) –  Apr 14 '12 at 09:22
  • @Iridio yes it is running in a webbrowser.i want to add a button to the browser when pressed it will send information to the c# program. – user1333001 Apr 14 '12 at 09:25
  • 1
    In your C# program implement a web service than when you click print in a html action contol send the request to the webservice whe request will be procesed in the server side and postback the result "price", use ajax/ – Harold Sota Apr 14 '12 at 09:27

1 Answers1

0

I'm not entirely clear how is your system set up so here is my assumption: You want to load some webpage (either locally or using URL) and communicate with that webpage using C# code. You might want to invoke a JavaScript function inside a webpage or you may want to listen to events in loaded webpage such as button click. All of these can be done by using Browser control. You can either create an instance of Browser control or use it in WinForms or WPF UI. I'm assuming your scenario is desktop app.

  1. If you want to invoke JavaScript function, use Browser.InvokeScript() method. There is a detailed article on how to do it.
  2. If you want to listen to events in browser control such as button click or link click then see this article for how-to.
  3. If you want to do more advanced customizations check out this C# wrapper.
Community
  • 1
  • 1
Shital Shah
  • 63,284
  • 17
  • 238
  • 185