Friday, September 03, 2010

How to find html tags and content inside rendered html in code behind

Finding html tags and tag content in the code behind is something you may find useful  when providing custom render time tweaks your asp.net website. By the render time you can control many more features like root URL and broken links etc. Following are two useful scripts that you may find useful when tweaking rendered html of asp.net pages.

Please consider this example:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <script language="javascript">
        function SayHello() {
            alert("Hello");
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <p>This is sample paragraph and this is my image 
            <img src="Images/Picture.jpg" alt="Picture" /></p>       
    </form>
</body>
</html>

Find tag:
Example: image tag <img>
<img src="Images/Picture.jpg" alt="Picture" />
Please refer this article for more information

Find tag content:
Example: script tag content <script>
function SayHello() {
    alert("Hello");
}
Please refer this article for more information

No comments:

Azure Storage Account Types

Defferent Types of Blobs Block blobs store text and binary data. Block blobs are made up of blocks of data that can be managed individually...