Take a look........
public void LoginIntoSite(ref SHDocVw.InternetExplorer
wbBrowser)
{
try
{
mshtml.HTMLDocument HTMLDoc;
do
{
} while (!(!(wbBrowser.Busy)));
HTMLDoc = (HTMLDocument)wbBrowser.Document;
IHTMLElementCollection iHTMLCol;
string str;
iHTMLCol = HTMLDoc.getElementsByTagName("input");
foreach (IHTMLElement iHTMLEle in iHTMLCol)
if ((iHTMLEle.getAttribute("name", 0)) != null)
//if (!(iHTMLEle.getAttribute("name",0) null))
{
str = iHTMLEle.getAttribute("name",
0).ToString();
if (str == "Userid")
{
iHTMLEle.setAttribute("value", "lgoetsch1",
0);
goto exitForStatement0;
}
}
exitForStatement0: ;
foreach (IHTMLElement iHTMLEle in iHTMLCol)
{
if ((iHTMLEle.getAttribute("name", 0)) != null)
{
str = iHTMLEle.getAttribute("name",
0).ToString();
if (str == "txtPassword")
{
iHTMLEle.setAttribute("value", "khurram1",
0);
goto exitForStatement1;
}
}
}
exitForStatement1: ;
foreach (IHTMLElement iHTMLEle in iHTMLCol)
{
if ((iHTMLEle.getAttribute("name", 0)) != null)
{
str = iHTMLEle.getAttribute("name",
0).ToString();
if (str == "submit")
{
iHTMLEle.click();
goto exitForStatement2;
}
}
}
exitForStatement2: ;
do
{
} while (!(!(wbBrowser.Busy)));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Bijgupt
|