javascript - How do you capture the result of a POST in the WebBrowser control? -


i have winforms form webbrowser control on it.

i've figured out how connect c# code javascript in web browser control attaching instance of c# class objectforscripting property, this:

public partial class browser : form {     private void webbrowser1_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e)     {         webbrowser1.objectforscripting = new scriptinterface();     } }  [permissionset(securityaction.demand, name = "fulltrust")] [comvisible(true)] public class scriptinterface {     public void dosomething(string data)     {         // interesting data here     } } 

... , call javascript this:

<button onclick=window.external.dosomething('with this')/> 

what haven't figured out yet how capture result of post operation form in webbrowser control, , use in c# code.

you perhaps use jquery post instead of form post.

assuming form has id of myform:

$( "#myform" ).submit(function( event ) {        // stop form submitting   event.preventdefault();    // values elements on page:   var $form = $(this),   var term = $form.find("input[name='s']").val(),   var url = $form.attr("action");    // send data using post   var posting = $.post( url, { s: term } )       .done(function(data) {           //pass response code           window.external.dosomething(data);       }); }); 

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -