Solved

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

Posted on 2007-11-21
3
215 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
Comment Utility
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
Comment Utility
try
m.GetAttribute("Type")
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Total in textboxes 9 34
Open a folder with partial name 14 27
Set form below another form 3 25
XML & .net 5 16
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

771 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