2008年6月16日 星期一

C# WebBrowser控制項填值範例

            HtmlElement ClickBtn = null;

            HtmlDocument doc = webBrowser1.Document;

            for (int i = 0; i < doc.All.Count; i++)

            {

                if (doc.All[i].TagName.ToUpper().Equals("INPUT"))

                {

                    switch (doc.All[i].Name)

                    {

                        case "e515e09":

                            doc.All[i].InnerText = "jkjkjk";

                            break;

                        case "e02e004":

                            doc.All[i].InnerText = "qqqqqq";

                            break;

                        case "s1":

                            ClickBtn = doc.All[i]; //提交按钮

                            break;

                    }

                }

            }

 

            try

            {

                ClickBtn.InvokeMember("Click");

            }

            catch (Exception ee)

            {

 

            }