WebBrowser - How to select HTMLElement as LIKE *FooterText ?

Posted on 2009-04-16
Last Modified: 2012-05-06
I need to select HTMLElement:
HtmlElement el = (HtmlElement)DOC.GetElementById("_ctl0__ctl0_rcList_rList__ctl2_lFooterText");
But part of this element differs by page - _ctl0__ctl0_rcList_rList__ctl2, _ctl0__ctl0_rcList_rList__ctl3.

I need to select from page an Element which ends with "_lFooterText".
Question by:exceter
    LVL 3

    Author Comment

    I tried to make as follows:
    string tmp = "_ctl0__ctl0_rcList_rList__ctl";
    int i = cnt;
    string linstr = tmp+i.ToString()+"_lFooterText";

    but cant know what the cnt will be,
    LVL 3

    Author Comment

    Better I did a simple counter in my program, which counts hits on page. It works now.
    LVL 8

    Expert Comment

    How about using a foreach to step through all the elements, get the id and look for the trailing _|FooterText
    LVL 3

    Author Comment

    I was thinking about that.
    But could not search for trailing. Can you show a simple code for that ?
    LVL 8

    Accepted Solution

    been a while since I worked in C#, not sure of the function names in C#

    two  approaches should work for you

    1) look for the characters _lFooterText with in the text.

    2) determine the len of the string and then do of substring from the length-12 to the _lFooterText  
    assume the id contains the name of the element.
    1) various languages call this instr, indexof, strpos not sure what it is called in C#
    if (strpos(id, "_lFooterText") > 0 ) then
         /* found a match */
    end if
    2) option 2
     ii = strlen(id)
     if (ii > 12) then
        if (strncmp(substring(id, ii -12), "_lFooterText",12) == 0 ) then
            /* found a match */
        end if
     end if

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
    Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now