hi,
i want to programmatically click a link on a asp.net web site. first i ve navigated to that website and i ve got a code from some other website

For i As Integer = 0 To Me.WebBrowser1.Document.Links.Count - 1
If Me.WebBrowser1.Document.Links(i).InnerHtml.StartsWith("Learn HTML") Then
Me.WebBrowser1.Document.Links(i).InvokeMember("Click")
End If
Next

but i dont know how and where to use it in my program code since im new to asp.net. can anybody help.

Thanks in advance.
Expecting fast replies guys.

>click on a asp.net webpage link programmatically

Use HttpWebRequest and it's methods.

>click on a asp.net webpage link programmatically

Use HttpWebRequest and it's methods.

thanks for ur reply,
since im new to .net i dnt know how to use this HttpWebRequest and its method in our progrm. So it will be helpful if u explain here with some sample code and how to use it in our program.

thanks..

Hi,

The code that you posted is to be used in WebBrowser control in Windows Forms application. It is not intend to be used in asp.net application.

In what do you want to click link? Server side or cliend side?

If you want to click a link using JavaScript, use the following code.

function ClickLink() { 
  document.getElementById('SomeLinkId').click(); 
}

thaks for ur reply Ramesh S,
but i ve tried as u said it does not take me to the corresponding page. for example i ve used bing site. this is t he code i ve used.

<html>
<head>
<script language="javascript">
function ClickLink() { 
document.webservices.submit();  
document.getElementById('sb_feedback').click(); 
}
</script>
</head>
<body>
<a href="javascript:ClickLink()">click me</a>
<form name="webservices" method=post action="http://www.bing.com/" target="new_window" onSubmit="window.open('', 'new_window', 'width=450,height=300,status=yes,resizable=yes,scrollbars=yes)"> 
</form>
</body>
</html>

check where im wrong.. expecting ur reply soon.

thanks

hey i really wondered that no body ve the knowledge in this stream to help me! y cant u help me regarding this since i need this for my project..


come on guys .... make ur reply soon..

>click on a asp.net webpage link programmatically

You can use Response.Redirect("uri") method.

thanks for replying,

but i cant achieve it using response.redirecct(url). i want to click an image button on some others website from my application..

pls do help..

expecting ur reply..

Please be more specific. Why don't you tell us what you're trying to do and we can tell you how to go about it.

hi,

every day i want to download some files from a clients web site and its my work.. so im trying now to automate that process to simplify my work if i did this it may help for others too in my office. my working process manually is
1.login into the website
2.click on a image button there
3.which will lead to next page of that site and there will be link to be clicked
4. when we click that link it will display the dialog box to open save or cancel the downloading attachments as usual.

i need to automate this..

i think im clear now..

help me to do this.

You can't click on that button/image programatically but you can get that resource using WebRequest if that button/image expose a url.

You can use HtmlAgilityPack (utility) to read/parse the html page and prepares the collection of links of resources.

Experts,
i ve asked a simple question only i think.. but i feel it difficult since im very new.. dont know why any of u not showing interest towards this.. and why u r not ready to share ur knowledge here and help people like me?

thanks for ur interest ,

And r u sure it can not be done programmatically... but i need to automate this process. so can u give some more details about how to use and where to implement this HtmlAgilityPack ..

thanks.

>i ve asked a simple question only i think

Yes it is but you failed to explain.

>dont know why any of u not showing interest towards this.

Undoubtedly no. Read our posts. You failed to show your interest since you haven't tried to put your work here.

>so can u give some more details about how to use and where to implement this HtmlAgilityPack

I don't seems any problem with googling.

Take a look :

1. http://htmlagilitypack.codeplex.com/Wikipage
2. http://blogs.msdn.com/smourier/archive/2003/06/04/8265.aspx
3. http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack
4. http://stackoverflow.com/questions/655603/html-agility-pack-parsing-tables

Thanks for replying..

ill seen through it.