dimanche 6 août 2017

using if statement in .html template page (inside tag)

Can anyone help me in using if statement in .html page.

I have a etemplate.html page. Inside its <span> tag i have some {values} which i am populating from code behind. like:

<!DOCTYPE html>
<html>
<head>
    <title></title>
    <meta charset="utf-8" />
</head>
<body>
    <div style="border-top:3px solid #22BCE5">&nbsp;</div>
    <span style="font-family:Arial;font-size:10pt">

        Hi <b>{Name}</b>,<br /><br />       
        Thank you for your order. Your project ID is {ProjId}. Your order 
        description is {description}.<br /><br />

  // for {summary} == "" the below code shows if(!=""){---...
  //I have tried using <% %> tags but not working

        if({summary}!=""){
          Your project summary is {summary}.
        }
</span>
</body>
</html>

And my populating method in c# is:

private string PopulateConfirmationEmailBody(string Name, string ProjId, 
string description, string summary)
        {
            string body = string.Empty;
            using (StreamReader reader = new 
            StreamReader(Server.MapPath("~/etemplate.html")))
            {
                body = reader.ReadToEnd();
            }
            body = body.Replace("{Name}", Name);
            body = body.Replace("{ProjId}", ProjId);
            body = body.Replace("{description}", description);
            body = body.Replace("{summary}", summary);
            return body;
}

Any help would be appreciated. Thanks in advance..!!

Aucun commentaire:

Enregistrer un commentaire