に誰もが.html
ページでif statement
を使用して私を助けることができる場合は使用して。文が(<span>タグ内)の.htmlテンプレートページ
私はetemplate.html
ページを持っています。その<span>
タグの中に私はいくつか{values}
を持っています。
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="utf-8" />
</head>
<body>
<div style="border-top:3px solid #22BCE5"> </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>
とC#で私の移入方法は次のとおりです:のような
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;
}
任意の助けいただければ幸いです。前もって感謝します..!!
これをチェック:https://forums.asp.net/t/1944993.aspx?How+to+use+if+else+condition+to+display+text+in+HTML+ – Sujith
@Sujithありがとうございます私は既に言いましたが、私はすでに<% %>を使ってみましたが、動作していません。 – Preet
あなたは実際にあなたのhtmlでコードを実行するために何もしていません。 Razorのようなパーサを通して実行する必要があります。パーサーは埋め込みコードを実行し、プレーンhtmlを出力します。 – juharr