Click here to Skip to main content
15,116,815 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, ive got a problem.In the first snippet I create a webbrowser() and navigate to a page, later in the function Settext() I want to get some html content of the page, In the line
HtmlElementCollection tagsCollection = webBrowser1.Document.GetElementsByTagName("input");
I set the source as webbrowser1, but in the first snippet I I create Browser, The question is, how do I determine where to search the content, If I have multiple tabs opened and every one of them contains a Browser. Hope I made It clear. Thank You

C#
WebBrowser Browser = new WebBrowser();
               tabControl2.TabPages.Add("New Page");
               tabControl2.SelectTab(zxc);
               Browser.Name = "Web Browser";
               Browser.Dock = DockStyle.Fill;
               tabControl2.SelectedTab.Controls.Add(Browser);
               Browser.Navigate("www.google.com");


C#
void SetText(string attribute, string attName, string value)
       {

           // Get a collection of all the tags with name "input";

           HtmlElementCollection tagsCollection = webBrowser1.Document.GetElementsByTagName("input");

           foreach (HtmlElement currentTag in tagsCollection)
           {


               // If the attribute of the current tag has the name attName

               if (currentTag.GetAttribute(attribute).Equals(attName))
               {
                   // Then set its attribute "value".

                   currentTag.SetAttribute("value", value);

                   currentTag.Focus();
               }
           }



           //  SendKeys.Send("{ENTER}");

       }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900