December 17, 2012

Dynamic HTML Template in Asp.Net


 Mail template with dynamic Variables


  • Open visual studio 2010,
  • then in your project add one HTML page.
  • Design / Add the content required in HTML page
  • Save this HTML page and then mark variables in [@your VariableName] format, so that you can find and replace that variable in code behind page.
  • Below is the sample code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
</head>
<body style="font-family: verdana; font-size: 10pt; background-color: #ffffcc;">
    <br />
    <table cellspacing="0" cellpadding="0" style="text-align: center; width: 75%; border: 1px;
        border-color: Black;">
        <tr>
            <td style="text-align: center;">
                <p style="text-align: left;">
                    Dear [User],,</p>
               
                <p style="text-align:  left;"></br>
                     As Requested , <br />
                     User ID: [UserID], <br />
                     Password : [Password]
                    <br />

                    Requested you to change your password after login.
                    <br />
                   
                </p>
                <p style="text-align: left;">
                    <br />
                    <br />
                    Best Regards,
                    <br />
                    <b>Admin</b><br />
                    <br />
                    <br />
                    (This is autogenerated email need not to be reply)
                </p>
                <br />
            </td>
        </tr>
        <tr>
            <td style="text-align: center;">
                &nbsp;</td>
        </tr>
    </table>
    </body>
</html>


Now with help of dataset you can find and replace the variables [User], [UserID] and [Password] with data in your dataset


No comments:

Post a Comment