I have a web page with some content and a button Save
. Through my C# code I want to change content of the webpage and then Click Save button. Here is my 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 does not save anything when clicking save. It does not even navigate to the page where it should after clicking Save button.
I noticed one strange thing. When I remove the first 3 lines to replace text and then change the content manually, everything works fine. Webpage saves content and navigates to proper location.
Any ideas to get a workaround?