tags:

views:

76

answers:

2

There may be an easier way, and if there is I'm all for it. However - my ASP.NET page has a TON of controls on it, and I've given them all ID's that start with underscore. I copied all the markup into Notepad++ and I'm trying to find a regular expression that will find everything but the controls and replace it with whitespace. that way I'll have a text file that has all my control names which I'll probably throw into Excel and do some string manipulation to add ".Text = " etc.

Any suggestions?

A: 

A significant advantage of FrontPage 2003 ($) and SharePoint Designer 2007 (free) (if you have one of them installed) are their ability to access a document through VBA.

You can do the same thing by loading the web page into a WebBrowser control and accessing the HtmlDocument class through the Document property.

I cannot find my VBA code that does exactly what you want, but I did find the following procedure that may help.

Option Explicit

Sub GatherFieldNames()
    Dim tag  As FrontPageEditor.IHTMLElement
    Dim i As Long
    Dim sDoc As String

    sDoc = vbNullString
    For i = 0 To ActiveDocument.all.Length - 1
        Set tag = ActiveDocument.all.Item(i)
        Select Case LCase$(tag.tagName)
            Case "form"
            Case "input", "select", "textarea"
                'sDoc = sDoc & Trim$(tag.Name) & vbCrLf
                'or
                sDoc = sDoc & Trim$(tag.getAttribute("name")) & vbCrLf
            Case "option"
                'included with select
            Case "table", "tbody", "tr", "td"
            Case "b", "font"
            Case "br", "p", "div", "hr", "span"
            Case "a", "img"
            Case "html", "head", "meta", "body", "script", "title", "link"
            Case "h1", "h2", "h3", "h4", "h5", "h6"
            Case "strong"
            Case "webbot"
            Case Else
              Debug.Print tag.tagName
        End Select
    Next i

End Sub
AMissico
+1  A: 

If you just want all the control names you could easily enumerate over your Page.Controls collection at runtime (descending into child controls, if necessary) and print out a list in whatever format you want, even adding your ".Text = ..." right there.

Evgeny