First of all, sorry for my bad English.
The question is very simple. I want to click on a link with C# (windows forms)
This is the code that I use:
int number_to_show = Convert.ToInt32(listView1_new_message.SelectedItems[0].SubItems[4].Text);
int a_to_click = (number_to_show * 5) + 2;
string titel_of_message = listView1_new_message.SelectedItems[0].SubItems[1].Text;
HtmlWindow SContentFrame = webBrowser1.Document.Window.Frames[1];
HtmlWindow Frame_A = SContentFrame.Document.Window.Frames[2];
HtmlElementCollection links = Frame_A.Document.GetElementsByTagName("b");
int link_counter = 0;
foreach (HtmlElement link in links) {
if (link_counter == a_to_click && link.InnerText.Equals(titel_of_message)) {
link.InvokeMember("Click");
}
link_counter++;
}
And it wants to click (I see it happening in debugging, and when I do a messagebox with the clicking, the messagebox appears), but the webpage don't react.
This is the htmlcode that is in the tag on the webpage:
<b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=7613BA4BF987D55FD171D53FAA24A259C7FDE435&userid=*******&seq=+Q&auth=+A&srcfolder=INBOX&uid=3291&srch=0&style=default'); return false">Doorgest: testing 2</a></b>
So somehow it doesn't click on the text... (or doesn't activate the onclick event handler)
How can I make the program work like it should be?
Thanks in advance :D TWCrap
EDIT 1 This is the piece of code of the table holding al the emails....
<table width="100%" border="0" cellspacing="0" cellpadding="0" align="center">
<tbody><tr valign="middle" bgcolor="#f0f0f0">
<td width="20" align="center"><input type="checkbox" name="CheckAll" onclick="ToggleCheckAll()"></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><font face="Verdana" size="2" color="#141F78"><b>!!</b></font></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt=""></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center"><img src="/graphics/telfort/attachments.gif" width="20" height="21" border="0" alt=""></td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"> <a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=1&style=default&start=100&end=1'); return false">Van </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=5&style=default&start=100&end=1'); return false">Onderwerp </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=7&style=default&start=100&end=1'); return false">Ontvangen </a> </td>
<td width="1"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td class="mailtitlebar"><a href="" onclick="NavA('/mail/MessageSort?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&sort=9&style=default&start=100&end=1'); return false">Grootte </a> </td>
</tr>
<tr><td colspan="15" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td></tr><!-- Message List Head --><!-- Message List --><tr valign="middle">
<td width="20" align="center" bgcolor="#f0f0f0"><input type="checkbox" name="msguid" value="3330"></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center">
<script>
var stat = '<IMG SRC="/graphics/priority_normal.gif" BORDER=0 width="10" height="18"><IMG SRC="/graphics/new.gif" BORDER=0 width="20" height="18"><IMG SRC="/graphics/attach_none.gif" BORDER=0 width="8" height="18">';
</script>
<script>
if (stat.indexOf('high.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!!</b></font>');
}
else if (stat.indexOf('low.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!</b></font>');
}
</script></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center" bgcolor="#ffffff"><script>
if (stat.indexOf('new.gif') > -1)
{
document.write ('<img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt="">');
}
else if (stat.indexOf('deleted.gif') > -1)
{
document.write ('<img src="/graphics/telfort/cancel.gif" width="20" height="20" border="0" alt="">');
}
else if (stat.indexOf('replied.gif') > -1)
{
document.write ('<img src="/graphics/telfort/reply.gif" width="20" height="20" border="0" alt="">');
}
else
{
document.write ('<img src="/graphics/telfort/mailopen-icon.gif" width="20" height="20" border="0" alt="">');
}
</script><img src="/graphics/telfort/mail-icon.gif" width="20" height="20" border="0" alt=""></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center" bgcolor="#ffffff"><script>
if (stat.indexOf('attach.gif') > -1)
{
document.write ('<img src="/graphics/telfort/attach-icon.gif" width="20" height="20" border="0" alt="">');
}
</script></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&uid=3330&srch=0&style=default'); return false">Tweakers.net Nieuwsbrief</a></b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b><a href="" onclick="OnPhoenixRead('/mail/MessageRead?sid=3B886D11EEAAF546F83EFAA8506E56BC30949BC9&userid=marcmeesters%40telfort.nl&seq=+Q&auth=+A&srcfolder=INBOX&uid=3330&srch=0&style=default'); return false">Samsung toont info eerste Windows Phone ...</a></b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b>jul 30</b></td>
<td width="1" bgcolor="#ffffff"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td bgcolor="#ffffff" class="mailtxt"> <b>42.9 KB</b></td>
</tr>
<tr><td colspan="15" bgcolor="#bbbdbf"><img src="/graphics/telfort/null.gif" height="1" width="1"></td></tr>
<!-- Message List end--><tr valign="middle">
<td width="20" align="center" bgcolor="#f0f0f0"><input type="checkbox" name="msguid" value="3329"></td>
<td width="1" bgcolor="#f0f0f0"><img src="/graphics/telfort/null.gif" height="1" width="1"></td>
<td width="20" align="center">
<script>
var stat = '<IMG SRC="/graphics/priority_normal.gif" BORDER=0 width="10" height="18"><IMG SRC="/graphics/new.gif" BORDER=0 width="20" height="18"><IMG SRC="/graphics/attach_none.gif" BORDER=0 width="8" height="18">';
</script>
<script>
if (stat.indexOf('high.gif') > -1 )
{
document.write ('<font face="Tahoma" size="2" color="#141D7C"><b>!!</b></font>');
}
<!-- Message List end--></tbody></table>