473,396 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WebBrowser 2.0

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

Nov 21 '06 #1
4 1155
Hi Le Minh,

Can you show us the html source?

--
Dave Sexton

"Le Minh" <ha*******@hotmail.comwrote in message
news:09**********************************@microsof t.com...
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

Nov 21 '06 #2
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 += "<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>";
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 += "<TD valign=top>";
strHtml += "<IMG src=" + baitin.LinkAnh + "
>";
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>";
-----------------------------
then: wb.DocumentText = strHtml;

Nov 21 '06 #3
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>");

--
With regards
Anders Borum / SphereWorks
Microsoft Certified Professional (.NET MCP)
Nov 21 '06 #4
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.. ";

--
Dave Sexton

"Le Minh" <ha*******@hotmail.comwrote in message
news:AC**********************************@microsof t.com...
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 += "<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>";
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 += "<TD valign=top>";
strHtml += "<IMG src=" + baitin.LinkAnh + "
";
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>";
-----------------------------
then: wb.DocumentText = strHtml;

Nov 21 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads,...
5
by: SPE - Stani's Python Editor | last post by:
Hi, During optimizing SPE for Ubuntu, I found something strange. I have Ubuntu 5.10 "The Breezy Badger" and unfortunately this code is not working: >>> import webbrowser >>>...
12
by: Alex Clark | last post by:
Greetings, (.NET 2.0, WinXP Pro/Server 2003, IE6 with latest service packs). I've decided to take advantage of the layout characteristics of HTML documents to simplify my printing tasks, but...
8
by: Prosperz | last post by:
Hi, I would like to make thumbnails of web page by capture content of a WebBrowser. By example, capture http://www.google.com. I used WebBrowser control with Framework 2.0. I try this : ...
8
by: Dustan | last post by:
At http://docs.python.org/whatsnew/modules.html on the webbrowser module, it says "A number of additional browsers were added to the supported list such as Firefox, Opera, Konqueror, and elinks." ...
11
by: Anil Gupte | last post by:
....and how do I insert one into my form? I used in VB 6.0 last, but cannot figure out where it is in .Net Thanx, -- Anil Gupte www.keeninc.net www.icinema.com
18
by: Zytan | last post by:
I have multiple threads writing to WebBrowser (using a function that checks InvokedRequired, and if so, invokes itself on the WebBrowser thread) and they are getting deadlocked. They only...
4
by: Gregory Bloom | last post by:
I'm running Python 2.5 under Windows. If I fire up IDLE and enter: it works like a champ, opening the page in Firefox. Same thing goes from a Windows cmd shell: it works as advertised. But...
11
by: kimiraikkonen | last post by:
Hi there, I needed to use MouseOver event on Webbrowser which is NOT provided by webbrowser control natively(what a disappointment), so i decided to go with another route to simulate this like: ...
3
by: TedTrippin | last post by:
Hi, Background - I've create a windows application in VS and added a WebBrowser component and all works well. I'm now trying to do this programmatically. My application now listens on a socket...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.