Solved

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

Posted on 2007-11-21
3
217 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

863 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

19 Experts available now in Live!

Get 1:1 Help Now