Here is my code;

// Allows writing to web forms
        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)
                //  Displays all the tags in a combobox
                comboBox1.Items.Add(currentTag.GetAttribute(attribute).ToString() + Environment.NewLine);

            // displays required tag
            comboBox1.SelectedIndex = 8; 


            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);       

and it's invoked by;

SetText("name", "user_name", "admin");

SetText("name", comboBox1.Text, "telus");

The problem I am having is that I can't pass the text of comboBox1 as the attname but I have to do this as the tag name is different every time I refresh the page.

Can someone show me where I am going wrong please

Edited by buster2209: n/a

7 Years
Discussion Span
Last Post by buster2209

Marked as solved.

I needed to remove "+ Environment.NewLine" from line 12.

It was adding an extra char to the attname I wanted which was making it useless.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.