using mshtml on c#


i want write html page in there 2 text boxes , 1 button. when click button want start activex control text textbox , run javascript “play” text in text boxes. i’ve got spread in 3 files: .html, .js , .cs. i’m not using visualstudio, notepad++ , command csc build .cs class.

to call javascript i’m trying use mshtml.execscript can’t recognize mshtml.dll. i’ve tried adding using mshtml; doesn’t work although dll placed in same folder .cs when try build it. should else able use .dll?

i know looks strange it’s simulation of makes sense ;)

my .cs looks follows. thank much!

 

using system;

using system.runtime.interopservices;

using system.collections.generic;

using system.text;

using system.threading;

using mshtml;

namespace anamespace 

{

 

  public interface asignatures

  {

    string fname();

    string password();

  }

  [classinterface(classinterfacetype.autodual)]

  public class aclass :asignatures

  {

    public string fname()

    {

         string textbox ="";

      return textbox;

    }

       public string password()

       {

         string pwd = "aaabb";

         return pwd;

       }

     public void setpage(mshtml.htmlwindow2class jsfile) {

           window = jsfile;

    } 

     public void init()

    {

       window.execscript("getuser()", "jscript");

       string pwd = "aaabb";

       string user = "user";

       window.execscript("setpassword(pwd)","jscript");

    }  

}

}

hi

the code cannot recognize  mshtml.dll if put .cs , dll @ same folder. because have not created project visual studio, cannot add reference dll manually or commandline.

another choice may use refection perform method need.

example:

using system.reflection;   using system.io;   try   {   assembly = null;   = assembly.loadfrom(application.startuppath startuppath + "myassembly.dll");  type classtype = a.gettype("mynamespace.myclass");   object obj = activator.createinstance(classtype);   methodinfo mi = classtype.getmethod("mymethod");   mi.invoke(obj, null);   }   catch (exception e)   {    addlog(e.message);    }        

you can call the method(mymethod) in myassembly.dll dynamically.

also may use commandline have try.

http://social.msdn.microsoft.com/forums/en-us/csharpide/thread/9d07fd41-7bde-465b-88f6-8fdb07a28d63

but best choice should to use visual studio ide, you save time via it. easy solve using vs.

you can download here.

http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-csharp-express

hope can you.


cookie luo[msft]
msdn community support | feedback us
get or request code sample microsoft
please remember mark replies answers if , unmark them if provide no help.




Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'