hrolsons
asked on
Click button on form using code
How can I click this button automatically:
<a id="ctl04_hypImage" href="folder.aspx?i=926241 3" title="Files: 242 Size: 1656.4 MB Creation Date: 1/26/2011">
<img style="border-width:0px;" src="http://www.winkflash.com/photo/imagew3.aspx?i=436827807&c=9262413&z=0" title="Files: 242 Size: 1656.4 MB Creation Date: 1/26/2011">
</a>
I tried:
WebBrowser2.Document.All.I tem("ct104 _hypImage" ).Click
WebBrowser2.Document.getEl ementById( "ct104_hyp Image").Cl ick
But neither worked.
<a id="ctl04_hypImage" href="folder.aspx?i=926241
<img style="border-width:0px;" src="http://www.winkflash.com/photo/imagew3.aspx?i=436827807&c=9262413&z=0" title="Files: 242 Size: 1656.4 MB Creation Date: 1/26/2011">
</a>
I tried:
WebBrowser2.Document.All.I
WebBrowser2.Document.getEl
But neither worked.
ASKER
I see that code is for .NET, would it work for VB6?
Oh sorry - I thought you were using ASP.NET. I've done some scouring and I'm not too sure you can achieve this in VB6. I think that's probably why we now have PerformClick in .NET.
Hopefully someone else will come along and prove me wrong, otherwise I think you're out of luck.
Hopefully someone else will come along and prove me wrong, otherwise I think you're out of luck.
Add this in the head:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
function clickbutton(){
$("#ctl04_hypImage").click ();
}
</script>
You can see example and tutorials at:
http://docs.jquery.com/Tutorials:Live_Examples_of_jQuery
http://www.roseindia.net/ajax/jquery/
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
function clickbutton(){
$("#ctl04_hypImage").click
}
</script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
function clickbutton(){
$("#ctl04_hypImage").click();
}
</script>
You can call the javascript function clickbutton() any way you want. I have used a library called jquery.You can see example and tutorials at:
http://docs.jquery.com/Tutorials:Live_Examples_of_jQuery
http://www.roseindia.net/ajax/jquery/
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script>
function clickbutton(){
$("#ctl04_hypImage").click();
}
</script>
sorry the codes went multiple times :)
ASKER
I must be in an alternate universe. I asked a "Visual Basic" question in the "Visual Basic Classic" section and first answer I got was VB.NET and the next was JavaScript.
Does anyone have a Visual Basic 6.0 answer, please-o-please?
Does anyone have a Visual Basic 6.0 answer, please-o-please?
@hrolsons
I would have tried the same thing you tried.
If you don't get an answer in the next couple of days, please click the Request Attention link and ask for more expert eyes on this question.
I would have tried the same thing you tried.
If you don't get an answer in the next couple of days, please click the Request Attention link and ask for more expert eyes on this question.
try WebBrowser2.Document.getEl ementById( "ct104_hyp Image").In vokeMember ("click")
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
http://msdn.microsoft.com/en-us/library/system.windows.forms.ibuttoncontrol.performclick.aspx
Let me know how you get on.
Ady