Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET3.5 VS2008 HTML WebForms , +
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
 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 19-Jul-10 17:55pm
Edited 19-Jul-10 17:58pm
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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();
  Permalink  
Comments
amitupadhyay007353543543 at 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 ?
amitupadhyay007353543543 at 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)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 485
1 OriginalGriff 310
2 Shweta N Mishra 244
3 Mathew Soji 225
4 BillWoodruff 200
0 OriginalGriff 6,153
1 Sergey Alexandrovich Kryukov 5,758
2 DamithSL 4,958
3 Manas Bhardwaj 4,539
4 Maciej Los 3,735


Advertise | Privacy | Mobile
Web01 | 2.8.1411019.1 | Last Updated 20 Jul 2010
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100