Click button on form using code

How can I click this button automatically:

<a id="ctl04_hypImage" href="folder.aspx?i=9262413" 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.Item("ct104_hypImage").Click
    WebBrowser2.Document.getElementById("ct104_hypImage").Click

But neither worked.
hrolsonsAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ady FootSharePoint ConsultantCommented:
I think you're looking for .PerformClick.

http://msdn.microsoft.com/en-us/library/system.windows.forms.ibuttoncontrol.performclick.aspx

Let me know how you get on.

Ady
0
hrolsonsAuthor Commented:
I see that code is for .NET, would it work for VB6?
0
Ady FootSharePoint ConsultantCommented:
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.  
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

liveaspankajCommented:
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>
 
<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>

Open in new window

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>

Open in new window

0
liveaspankajCommented:
sorry the codes went multiple times :)
0
hrolsonsAuthor Commented:
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?
0
aikimarkCommented:
@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.
0
tpaynCommented:
try WebBrowser2.Document.getElementById("ct104_hypImage").InvokeMember("click")
0
tpaynCommented:
my apologies hrolsons you need a VB6 solution and i just jump in with InvokeMember .. i hang my head in shame.

I have created a test project quickly .. you misspelled the id in your example

Dim element        
        Set element = WebBrowser1.document.getElementById("ctl04_hypImage")
        If Not element Is Nothing Then
            element.Click
        End If

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.