c# - Changing content of webpage -


i have web page content , button save. through c# code want change content of webpage , click save button. here code.

string replace = webbrowser1.documenttext.replace("2013.0.0.1", "2013.0.0.2"); webbrowser1.documenttext = replace;  links = webbrowser1.document.getelementsbytagname("input"); foreach (htmlelement link in links) {     if ((link.getattribute("name") == "save"))     {         if (link.getattribute("type").equals("submit"))         {             link.invokemember("click");             break;         }     } } 

my website not save when clicking save. not navigate page should after clicking save button.

i noticed 1 strange thing. when remove first 3 lines replace text , change content manually, works fine. webpage saves content , navigates proper location.

any ideas workaround?

ultimately got it. realized approach not correct. got text html , trying replace text in that. noticed later text present in textarea. fetched text of textarea , replaced text. hitting save working fine. here code:

htmlelementcollection links = webbrowser1.document.getelementsbytagname("a");  links = webbrowser1.document.getelementsbytagname("textarea"); foreach (htmlelement link in links) {     if ((link.getattribute("name") == "text"))     {         string attribute = link.innertext;         string replace = attribute.replace(@"hello world", @"helo world!!!");         link.innertext = replace;         break;     } }  links = webbrowser1.document.getelementsbytagname("input"); foreach (htmlelement link in links) {     if ((link.getattribute("name") == "save"))     {         if (link.getattribute("type").equals("submit"))         {             link.invokemember("click");             break;         }     } } 

hope helps.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -