How can I search for instances of static text in the markup of ASP.NET pages and controls?
I've got an internationalised web application in which all the text that eventually gets sent to the browser is generated by code-behind, either by usercontrols that override Render, or by code that sets the Text of Label etc controls.
For example, rather than an aspx containing
<h2>Subtitle</h2> <p>Some paragraph</p>
this application would have instead
<h2><asp:Label runat="server" ID="SubTitle" /></h2> <p><mycontrols:Literal runat="server" ID="Paragraph" /></p>
with the actual text only getting supplied at runtime.
I would like to ensure that I haven't inadvertently left any static text in the markup anywhere. However, the ways I can think of all have flaws:
- I can't use a tool that tries to parse the markup as xml, because *.as?x markup definitely isn't valid xml
- I can't even use an html parser (such as HtmlAgilityPack), because *.as?x markup (remembering this is before it's rendered by ASP.NET) also isn't necessarily valid html (consider how repeater templates can interleave tags)
- Just using Visual Studio Find won't help me find just static text and not, say, CSS class names
Is there any way other than manually checking through every page?
Ok, so if it's a a site supporting internationalisation - point one of the many free web site downloaders apps at it - and pull the output onto disk. Run it in French (or language of your choice) then German. Any harcoded text strings will not change. You'll then have to find a WinMerge tool (I think WinMerge can do folders) or write something that can file compare the output. Then PowerGrep to locate the results back in your source.