WebBrowser 2.0

  • Thread starter Thread starter Le Minh
  • Start date Start date
L

Le Minh

Hi everyone!
When i'm using .net 2.0 webbrowser control, I generate html code at runtime,
and bind it to wb.DocumentText Property. But, when i click the link in the
wb, the wb isn't navigate to this link. why this ?
Anyone can help me ?

Thanks
 
here it is...
----------------
foreach (BaiTin baitin in baitins._BaiTin)
{
string strMoTa = baitin.MoTa;

string strLocation = htmlpath + baitin.BaiViet;
// strLocation = strLocation.Replace(" ", "%20");

string strHref = "<a href=\"" + strLocation + "\"
if (first)
{
first = false;
strHtml += "<TR><TD colspan=2>";
strHtml += "<TABLE><TR>";
strHtml += "<TD colspan=2 align=center>";
strHtml += strHref + " <H2>" + baitin.TieuDe +
"</H2></A>";
strHtml += "</TD>";
strHtml += "</TR>";

strHtml += "<TR valign=top>";
strHtml += "<TD valign=top>";
strHtml += "<IMG src=" + baitin.LinkAnh + " >";
strHtml += "</TD>";
strHtml += "<TD> <P align=justify>";
strHtml += baitin.MoTa;
strHtml += "</P></TD>";
strHtml += "</TR>";

strHtml += "<TR>";
strHtml += "<TD colspan=2>";
strHtml += baitin.Nguon;
strHtml += "</TD>";
strHtml += "</TR></TABLE>";
strHtml += "</TD></TR>";

left = true;
}
else
{
if (left)
{
strHtml += "<TR><TD>";

strHtml += "<TABLE><TR>";
strHtml += "<TD colspan=2>";

strHtml += strHref + " <H3>" + baitin.TieuDe
+ "</H3></A>";
strHtml += "</TD>";
strHtml += "</TR>";

strHtml += "<TR valign=top>";
strHtml += said:
strHtml += "</TD>";
strHtml += "<TD> <P align=justify>";
strHtml += baitin.MoTa;
strHtml += "</P> </TD>";
strHtml += "</TR>";

strHtml += "<TR>";
strHtml += "<TD colspan=2>";
strHtml += baitin.Nguon;
strHtml += "</TD>";
strHtml += "</TR></TABLE>";
strHtml += "</TD>";
left = false;
}
else
{
strHtml += "<TD>";

strHtml += "<TABLE><TR>";
strHtml += "<TD colspan=2>";
strHtml += strHref + " <H3>" + baitin.TieuDe
+ "</H3></A>";
strHtml += "</TD>";
strHtml += "</TR>";

strHtml += "<TR valign=top>";
strHtml += "<TD> <P align=justify>";
strHtml += baitin.MoTa;
strHtml += "</P></TD>";
strHtml += said:
strHtml += "</TD>";
strHtml += "</TR>";

strHtml += "<TR>";
strHtml += "<TD colspan=2>";
strHtml += baitin.Nguon;
strHtml += "</TD>";
strHtml += "</TR></TABLE>";
strHtml += "</TD></TR>";
left = true;
}
}
}
strHtml += "</TABLE>";
strHtml += "</BODY>";
strHtml += "</HTML>";
 
Hi Le Minh

Not answering your original question, here's a tip. For improved
performance, change the string concatenation calls with calls to a
StringBuilder (available from the System.Text namespace).

// instead of
strHtml += "<TR><TD colspan=2>";

// use the following
StringBuilder builder = new StringBuilder();
builder.Append("<TR><TD colspan=2>");
 
Hi Le Minh,

Could you post just the output HTML of the hyperlink?

If the value is in the format, "http://some_url.com" then maybe you could
post a short but complete program that reproduces your exact problem, a la
Jon Skeet's http://www.yoda.arachsys.com/csharp/complete.html article.

1. I don't know the value of htmlpath and baitin.BaiViet
2. Your approach to concatenating strings is confusing and not recommended
A. Use a StringBuilder
B. Use a resource string with replacement tokens (preferred in some
cases)
C. Use a verbatim literal (preferred in other cases):

string strHtml =
@"<TR><TD colspan=2>
<TABLE><TR>
<TD colspan=2 align=center>
" + strHref + "<H2>" + baitin.TieuDe + "</H2></A>" +
@" </TD>
</TR>

etc.. ";
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top