Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I receive JSON formated data into C# method argument
    primarykey
    data
    text
    <p>I am using WebKit browser control in my .net application. I am also new to JSON and have little knowledge of Java script. My is to call one method C# method from java script code. I know there is "ObjectForScripting" property with WebKit control.</p> <p><strong>C# Code:- This code get executed on one of the button click. Which inject java script into rendered HTML page.</strong></p> <pre><code>Element scriptElm = browser.Document.CreateElement("script"); scriptElm.AppendChild(browser.Document.CreateTextNode("Test(['ABC','EFG'],{'name':'First Name','surname':'LastName'})")); NodeList headElm = browser.Document.GetElementsByTagName("head"); headElm[0].AppendChild(scriptElm); </code></pre> <p>Above code calls below Java script method from rendered HTML page.</p> <p><strong>Java Script code:</strong></p> <pre><code>function Test(arg1,arg2) { document.write(arg2.name); // Printing correct i.e. Firstname document.write(arg2); // Bad!!!! always print [Object object] window.external.TestMethod(arg1,arg2); // Call method in C# code. } </code></pre> <p><strong>C# Method signature</strong></p> <pre><code>public bool TestMethod(string obj1, String obj2) { MessageBox.Show(obj1.ToString()); MessageBox.Show(obj2.ToString()); return true; } </code></pre> <p>So in above callback method I am not able to get second parameter i.e.obj2 correctly. In C#. I always get it as Object. I tried setting that to Object but didn't work.How should I convert it into right format? </p> <p>Thanks, Omky</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload