c# - WebBrowser Control is opening multiple windows -


i writing windows forms application interface component has built in web server used changing device's settings. think of router configuration page. want interact device via post , commands configuration page performs. being said, i'm using webbrowser control item. in below code, when run, opens 2 ie windows. prefer not open windows, or @ least, open , let me close window. can me perform this?

using system.text; using system.threading; using system.windows.forms; using device.model; using device.view;  namespace devicename.controller.staticclasses {     public static class deviceadapter     {         private static device _device;         private static string _pword;          public static void getdhcporstatic(device selecteddevice, string txtpassword, frmmainform mainform)         {             _device = selecteddevice;             _pword = txtpassword;              var browserthread = new thread(getdhcporstaticthread);             browserthread.setapartmentstate(apartmentstate.sta);             browserthread.start();         }          public static void getdhcporstaticthread()         {             var browser = new webbrowser {visible = false};              var url = "http://" + _device.ipaddress;             var postdata = "redirect=index.htm&.password=" + _pword;             var encoding = encoding.utf8;              var postbytes = encoding.getbytes(postdata);              browser.navigate(url, "_blank", postbytes, "content-type: application/x-www-form-urlencoded");             browser.documentcompleted += dhcporstatic_documentcompleted;         }          private static void dhcporstatic_documentcompleted(object sender, webbrowserdocumentcompletedeventargs e)         {             ((webbrowser) sender).visible = false;         }     } } 


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -