Hello,
we have a Windows Application in which has the CEFSharp Browser implemented. What’s the best way to send data from the windows app to the WiseJ App? I’ve read that WiseJ can’t react on POST Requests, so I tried just calling some JavaScript function, but the CEFSharp FrameLoadEnd Event is too early.
Lastly I tried defining a JS function in the Browser like this (data is properly escaped for a string):
string script = "function GetJSData(){ " + "return \"" + data + "\"; " + "}"; IFrame frame = browser.GetMainFrame(); frame.ExecuteJavaScriptAsync(script);
And on the WiseJ side I have this:
public partial class PostPage : Page { private NameValueCollection _args; public PostPage(NameValueCollection args) { _args = args; InitializeComponent(); this.Load += PostPage_Load; } private void PostPage_Load(object sender, EventArgs e) { this.Eval("App.PostPage.Commit(GetJSData());"); } [WebMethod] public void Commit(string data) { this.textBox1.Text += "param: " + _args.Get("param") + Environment.NewLine + "Data: " + data + Environment.NewLine; } }
This works, but maybe there is an easier or more elegant approach?
Thanks in advance
Hi Sascha,
You can have your own javascript functions in your Wisej.NET’s application and you can then later call them from your WinForms app.
This can be done either directly from your Default.html page (i.e. you write your scripts there), or you can add a js to your project’s “Platform” folder.
If you go with the latter, you should uncomment the line // [assembly: Wisej.Core.WisejResources(ExcludeList: "")] in your AssemblyInfo.cs
file so that your .js files are actually embedded and loaded into the application.
Other than that, using WebMethods is also fine!
HTH,
Alaa
Please login first to submit.