Windows Develop Bookmark and Share   
 index > Windows Forms General > WebBrowser form/method/name help
 

WebBrowser form/method/name help

ok, on the webpage my webbrowser navigates to there is 4 forms, 4 names, and 4 different names, i will explain

on the first form its called "Info", now on this form it has a drop down menu for age,
i have the name of the dropdown menu, its agemnth, and here is the code for it from the webpage source

Code Snippet

		<select name="agemnth"  onChange = "javascript:document.formInfo.submit()">
<option value="0">January</option>
and it keeps goin... option value 1 will = febuary..ect


now is there a way i can change the value of the agemnth , then submit the form itself?
Also: it submit the form automaticly when you change the value of the dropdownbox, so i need it to do that too,
i just need to change the value in the dropdown box

Note: i have tried looping an HtmlElement untill its name is agemnth , then using ele.Innertext == "March";

then Web.Document.Forms["Info"].Invokemember("submit");

also i hav tried changing the "march" to its id in the source code, 03. still didnt work

Speak  Saturday, March 15, 2008 4:38 AM

Hi,

You should set the value property instead of the InnerText, and notice thatyou should useelementId intead of element name to index the form in the Formscolletion,something like this:

Code Snippet

void button1_Click(object sender, EventArgs e)

{

while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete)

{

Application.DoEvents();

}

this.webBrowser1.Document.

GetElementsByTagName("select").

GetElementsByName("agemnth")[0].

SetAttribute("value", "02");

this.webBrowser1.Document.Forms["infoForm"].InvokeMember("submit");

}



Best Regards
Zhi-xin Ye

Zhi-Xin Ye  Thursday, March 20, 2008 9:38 AM

Hi,

You should set the value property instead of the InnerText, and notice thatyou should useelementId intead of element name to index the form in the Formscolletion,something like this:

Code Snippet

void button1_Click(object sender, EventArgs e)

{

while (this.webBrowser1.ReadyState != WebBrowserReadyState.Complete)

{

Application.DoEvents();

}

this.webBrowser1.Document.

GetElementsByTagName("select").

GetElementsByName("agemnth")[0].

SetAttribute("value", "02");

this.webBrowser1.Document.Forms["infoForm"].InvokeMember("submit");

}



Best Regards
Zhi-xin Ye

Zhi-Xin Ye  Thursday, March 20, 2008 9:38 AM

You can use google to search for other answers

Custom Search

More Threads

• how to filter dataset more than once without using multiple filter statement at one go?
• How to keep a Splash Screen on while App Loading
• Public Enum
• Notify Icon Short Cut Keys to context menu
• Getting a CSV file into a dataset-ADO.NETor TextReader?
• Shell help
• Printing
• problems after closing an application
• How to prevent multiple instances of my App
• Print Preview button on Print dialog box