Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query To HTML In Web Browser Control
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Miscellaneous
Thread ID:
01379853
Message ID:
01379918
Views:
27
Here's what I did that seems to work....


I'm going to loop thru a DS of data and for each row write out a line to an HTML file, as in:
<a href="#product#">A6153AR</a>

or

<a href="#part#">A6171-69001</a>
Then I have the following C# code:
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
    HtmlElementCollection tags = webBrowser1.Document.Links;

    foreach(HtmlElement element in tags)
    {
        element.Click += new HtmlElementEventHandler(element_Click);
    }

}

void element_Click(object sender, HtmlElementEventArgs e)
{
    HtmlElement x = (HtmlElement)sender;

    string sId = x.InnerText;
    string sSection = x.OuterHtml;
    sSection = sSection.Replace("\"", "");

    char chSep = '#';
    string[] arrStr = sSection.Split(chSep);

    sSection = arrStr[1];

    LinkClicked(sSection, sId);

}

private void LinkClicked(string sSection, string sLinkText)
{
    switch (sSection.ToLower())
    {
        case "navigation":
            break;

        case "part":
            break;

        case "product":
            break;

    }
}
>>>>I was thinking of display query results in a web browser. The data will a categorized list of part numbers and other data. The part numbers will be links.
>>>>
>>>>I know I can used the Navigating event to trap when a link is clicked. The question is, how can I detect when a part hyperlink is clicked as opposed to some other link? Can I 'attach' anything to the link that I can test for?
>>>
>>>You can tell just by looking at the URL passed in the events of the Navigating event (as long as you make them unique in some way).
>>
>>
>>That's exactly the problem. There's nothing unique about the data. For example, a product number might be "A6153AR" and a part number might be "A4926A" or "A6153-10005". How would you know that the first is a product and the other two are parts?
>
>Do you control the code which generates the HTML? If so, just change the URL based on which link you're rendering. If you don't control this, about all you can do is compare a product link and a part link. If there literally is no difference except for the number (and they look identical to one another) you're out of luck.
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform