this is totally off the top of my head and Im sure there's an easier way.. but until someone replies it may give a head start if I recall - you set the postback event source and then submit the form.. I'll look quick for more info on it. that way asp.net knows where to route the request (ie who called it and what event to raise)
On Mon, Sep 8, 2008 at 4:42 PM, Clark, Michael (OFM) < [EMAIL PROTECTED]> wrote: > I am trying to figure out how to click a button on a web page > programmatically. > > Specifically, I have a WinForm with a WebBrowser control. Once it > navigates, in the DocumentCompleted event handler I have the following > set up for logging in: > > HtmlDocument doc = webBrowser1.Document; > > HtmlElement userID = doc.GetElementById("userIDTextBox"); > userID.InnerText = "user1"; > > HtmlElement password = doc.GetElementById("userPasswordTextBox"); > password.InnerText = "password"; > > HtmlElement button = doc.GetElementById("logonButton"); > button.RaiseEvent("onclick"); > > This fills the userid and password text boxes fine, but I am not having > any success getting that darned button to click; I've also tried > "click", "Click", and "onClick" -- what else is there?. A search of > msdn of course gives me no clues, nor groups.google.com. I gotta be > close. > > The button is coded: > > <input type="submit" name="logonButton" value="Login" onclick="if > (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " > language="javascript" id="logonButton" tabindex="4" /> > > =================================== > This list is hosted by DevelopMentor(R) http://www.develop.com > > View archives and manage your subscription(s) at > http://discuss.develop.com > =================================== This list is hosted by DevelopMentor® http://www.develop.com View archives and manage your subscription(s) at http://discuss.develop.com