Solved

How do I find the password in an <input> tag?

Posted on 2007-11-21
3
223 Views
Last Modified: 2010-04-23
In need to be able to tell which <input> tags have the 'password' type.

ex:
<input type="password" name="password" size="12">

Here is what  I have, but I have something wrong...

                    Dim htmlCollection As HtmlElementCollection = WebBrowser.Document.GetElementsByTagName("INPUT")
                    For Each elem As HtmlElement In htmlCollection
                        Dim ElemName As String
                        ElemName = elem.GetAttribute("password")
                        'elem.SetAttribute("password", Trim(strPassword))
                        'MessageBox.Show(elem.TagName, elem.)
                        If elem.GetAttribute("password") = "" Then
                            WebBrowser.Document.All(elem.Name).InnerText = Trim(strPassword)
                            bPassword = True
                            Exit For
                        End If
                    Next

Thanks!
0
Comment
Question by:jwhiteman1967
3 Comments
 
LVL 10

Expert Comment

by:Dxpert
ID: 20329232
Why are you complicating it like that?
Why can't you just make that password input, runat="server"?


ex:

'aspx
<input type="password" id="password" size="12" runat="server">



'aspx.vb
password.value = Trim(strPassword)
0
 
LVL 21

Expert Comment

by:surajguptha
ID: 20329245
try
m.GetAttribute("Type")
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 20329263
Try this:

Dim htmlCollection As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("INPUT")
For Each elem As HtmlElement In htmlCollection
    Dim InputType As String = elem.GetAttribute("type")
    If InputType.ToLower = "password" Then
        elem.InnerText = strPassword
        bPassword = True
        Exit For
    End If
Next
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

831 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