Go Back  Xtreme Visual Basic Talk > Visual Basic .NET (2002/2003/2005/2008, including Express editions) > .NET General > Invoking Click (or something) on HTML List


Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2012, 12:27 AM
_Mordred_'s Avatar
_Mordred_ _Mordred_ is offline
Freshman
 
Join Date: Jun 2011
Posts: 26
Default Invoking Click (or something) on HTML List


Hi all, I've come across an HTML listbox that I requires a selection but I do not know how to set its attribute via VB. I thought that
Code:
.GetElementById("exporterId").SetAttribute("value", 7)
where 7 would be the index representation of the selection I want to automate. This does not work so I also tried to invoke a click but I don't know how to apply that to an HTML list. I'm stumped and I hope I have been clear.
Reply With Quote
  #2  
Old 03-30-2012, 07:59 AM
AtmaWeapon's Avatar
AtmaWeapon AtmaWeapon is offline
Fabulous Florist

Forum Leader
* Guru *
 
Join Date: Feb 2004
Location: Austin, TX
Posts: 9,500
Default

The value of a listbox is the value that is selected. Not the index. So set it to the value you want to select.
__________________
.NET Resources
My FAQ threads | Tutor's Corner | Code Library
I would bet money 2/3 of .NET questions are already answered in one of these three places.
Reply With Quote
  #3  
Old 03-30-2012, 08:31 AM
_Mordred_'s Avatar
_Mordred_ _Mordred_ is offline
Freshman
 
Join Date: Jun 2011
Posts: 26
Default

Thanks AtmaWeapon, I'll try that as soon as I can and let you know how it goes.
Reply With Quote
  #4  
Old 03-30-2012, 08:04 PM
_Mordred_'s Avatar
_Mordred_ _Mordred_ is offline
Freshman
 
Join Date: Jun 2011
Posts: 26
Default

Hi AtmaWeapon, I tried
Code:
WebBrowser1.Document.GetElementById("exporterId").SetAttribute("value", "CSV file, time as rows")
and I also tried
Code:
WebBrowser1.Document.GetElementById("exporterId").InvokeMember("click", "CSV file, time as rows")
but neither select from the list. "exporterID" is the name of the list for certain. I'm slightly off on this and don't know what to add to the code to make the selection work. Any thoughts?
EDIT: I have also tried the GetElementByTagName with <option value> as its parameter
Code:
WebBrowser1.Document.GetElementsByTagName(ListTagName)
where ListTagName is a string but I don't understand what to do with it if it is found.
HTML and the selection I am after is in red:
Code:
<select name="exporterId" size="12" id="OutLst">
            <optgroup label="SCREEN OUTPUT formats">
                <option value="SERIES_HTML_TIME_AS_COLUMN">HTML table, time as columns</option>
                <option value="SERIES_HTML_TIME_AS_ROW">HTML table, time as rows</option>
                </optgroup>

                <optgroup label="DOWNLOADABLE FILE formats">
                    <option value="SERIES_CSV_TIME_AS_COLUMN">CSV (comma-separated values) file, time as columns</option>
                        <option value="SERIES_SCSV_TIME_AS_COLUMN">SCSV (semicolon-separated values) file, time as columns</option>
                        <option value="SERIES_CSV_TIME_AS_ROW">CSV file, time as rows</option>
                        <option value="SERIES_SCSV_TIME_AS_ROW">SCSV, time as rows</option>
                        <option value="SERIES_CSV_TIME_AS_COLUMN_DATA_QUALITY">CSV file, time as columns with data quality indicators</option>
                        <option value="SERIES_SCSV_TIME_AS_COLUMN_DATA_QUALITY">SCSV file, time as columns with data quality indicators</option>
                        <option value="SERIES_CSV_TIME_AS_ROW_DATA_QUALITY">CSV file, time as rows with data quality indicators</option>
                        <option value="SERIES_SCSV_TIME_AS_ROW_DATA_QUALITY">SCSV file, time as rows with data quality indicators</option>
                        </optgroup>
            </select>

Last edited by _Mordred_; 03-31-2012 at 02:04 AM.
Reply With Quote
  #5  
Old 03-31-2012, 02:09 AM
_Mordred_'s Avatar
_Mordred_ _Mordred_ is offline
Freshman
 
Join Date: Jun 2011
Posts: 26
Default

I set my value wrong, the following works. Such a silly mistake. It's all good now though.

Code:
WebBrowser1.Document.GetElementById("exporterId").SetAttribute("value", "SERIES_CSV_TIME_AS_ROW")
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->