Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
1.44/5 (2 votes)
See more: , +
the free microsoft word plugin is driving me nuts. Iam trying to fill html forms through vb.net using web browser control and GetElementById method.

On blogger home page when i try to login, i have to fill user name, passowrd and then click on submit button. When viewing the HTML source of the page, i get the elements as :


<big></big><h2>Sign in to use Blogger<br> with your Google Account</br></h2>
<div class="input-holder"><label for="Email">Username (Email):</label>
<input type="text" size="10" name="Email" id="Email" class="text" dir="ltr" tabindex="1"></input></div>
<div class="input-holder"><label for="Passwd">Password:
(<a href="http://www.blogger.com/forgot.g" title="Forgot your password?">?</a>)</label>
<input type="password" size="10" tabindex="2" name="Passwd" id="Passwd" class="text" autocomplete="off" dir="ltr"></input></div>
<div id="PersistentCookie-holder"><input type="checkbox" name="PersistentCookie" id="PersistentCookie" tabindex="3" value="yes">

<label for="PersistentCookie">Remember me</label>
(<a href="http://help.blogger.com/bin/answer.py?answer=42054" target="_top" title="What is "remember me"?">?</a>)</input></div>
<div id="signin-btn-holder"><script type="text/javascript">
  document.write("\x3cspan id\x3d\x22signin-btn\x22 class\x3d\x22ubtn\x22 onclick\x3d\x22if (this.className.indexOf(\x26quot;ubtn-disabled\x26quot;) \x3d\x3d -1) {var e \x3d document[\x26#39;login\x26#39;].ok;(e.length) ? e[0].click() : e.click(); if (window.event) window.event.cancelBubble \x3d true; return false;}\x22\x3e\x3cspan class\x3d\x22left\x22\x3e\x3cspan\x3e\x26nbsp;\x3cimg src\x3d\x22/img/blank.gif\x22 width\x3d\x221\x22 height\x3d\x221\x22 alt\x3d\x22\x22\x3e\x26nbsp;\x3c/span\x3e\x3c/span\x3e\x3cspan class\x3d\x22i\x22\x3e\x3ca href\x3d\x22javascript:void(0)\x22 tabindex\x3d\x224\x22 onclick\x3d\x22return false;\x22\x3eSign in\x3c/a\x3e\x3c/span\x3e\x3cspan class\x3d\x22right\x22\x3e\x3cspan\x3e\x26nbsp;\x3cimg src\x3d\x22/img/blank.gif\x22 width\x3d\x221\x22 height\x3d\x221\x22 alt\x3d\x22\x22\x3e\x26nbsp;\x3c/span\x3e\x3c/span\x3e\x3c/span\x3e");
</script>
<script type="text/javascript">
  document.write("\x3cinput type\x3d\x22submit\x22 id\x3d\x22signin-btn-hidden\x22 name\x3d\x22ok\x22 value\x3d\x22Sign in\x22 tabindex\x3d\x22-1\x22 style\x3d\x22position:absolute; display:block; width:0; padding:0;                z-index:-1; border:none; top:-5000px; left:-5000px\x22\x3e");
</script>
<noscript><input type="submit" id="signin-btn-ns" class="ubtn ubtn-inline" name="ok" tabindex="4" value="Sign in"></input></noscript></div>
<div class="r"></div>



so i get the elements by their id and now my code is :

<big>WebBrowser1.Document.GetElementById("Email").SetAttribute("value", "amit.tcet")
            WebBrowser1.Document.GetElementById("Passwd").SetAttribute("value", "151100151105")
            WebBrowser1.Document.GetElementById("signin-btn-ns").InvokeMember("click")</big>


but the button is not clicked and hence i cannot login.

any ideas what is wrong?
Posted
Updated 16-Oct-17 1:55am
v2

1 solution

I have done a similar like this here.

Here[^]

or try something like following.


mshtml.HTMLDocument obj;
obj=(mshtml.HTMLDocument)WebBrowser1.Document;
obj.getElementById("signin-btn-ns").click();
 
Share this answer
 
Comments
amit_upadhyay 20-Jul-10 3:13am    
thanks but since iam using vb.net could you tell me, what will be the second line in vb.net ?
amit_upadhyay 20-Jul-10 3:23am    
got it in vb.net (directcast), but this is not working. I have been able to automatically fill two other blog sites : blog.com and blog.co.in (without mshtml) but blogger doesn't seem to work.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900