c# - Call Class Method from other Class not working -
I'm trying to call the methods of the class "Form 1" of another class here is my code
namespace WindowsFormsApplication1 {public partial class} form 1: form {public form 1 () {InitializeComponent (); } Private void WebBrowser1_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e) {MessageBox.Show ( "load"); order. Objectforming = new script interface (); } Private void webBrowser2_DocumentCompleted (object sender, WebBrowserDocumentCompletedEventArgs e) {} private void button1_Click_1 (object sender, EventArgs e) {}} [System.Runtime.InteropServices.ComVisibleAttribute (true)] public class ScriptInterface {public void callme (string currid) { MessageBox.Show (currid); // The following security error throws Form1.webBrowser2.Navigate ("http://www.mywebpage.com/client/index.php?id=" + currid); }}} INFO: I have 2 webforcers. I am holding events from web browser 1 to update WebBrowser2. My problem is that I can not call webbrowser2 methods out of Form1.
Any ideas how can I solve this problem? The
Do not freeze your Vebbroj component (it's a good thing), so you form them directly 1 Can not send out because your code sample is trying to do this. You must get a reference to the form 1 example and then you can call methods on them, as long as they are not marked as public, depending on your needs it's probably just a reference to the WebBrowser components a straight and even better to pass along
maybe something like this:
orders.ObjectForScripting = new ScriptInterface (this .webBrowser2); ...
Public class ScriptInterface {Private WebBrowser _browser; Public Script Interface (web browser browser) {_browser = Browser; } Public Zero column (string cream) {_browser.Navigate ("http://www.mywebpage.com/client/index.php?id=" + currid); }}
Comments
Post a Comment