任何人都可以帮助我在.html页面中使用if statement。在.html模板页面中使用if语句(在标记中)
我有一个etemplate.html页面。在其标签里面,我有一些{values},我从后面的代码填充。这样的:在C#中
Hi {Name},
Thank you for your order. Your project ID is {ProjId}. Your order
description is {description}.
// for {summary} == "" the below code shows if(!=""){---...
//I have tried using tags but not working
if({summary}!=""){
Your project summary is {summary}.
}
我的填充方法是:
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;
}
任何帮助,将不胜感激。提前致谢..!!
2017-08-07
Preet
+0
选中此:https://forums.asp.net/t/1944993.aspx?How+to+use+if+else+condition+to+display+text+in+HTML+ –
+0
@Sujith感谢您建议,但正如我所提到的,我已经尝试使用,但不工作 –
+0
现在你实际上没有做任何事情来运行你的HTML代码。你需要通过像Razor这样的解析器运行它,它将运行嵌入式代码并输出纯html。 –