用ASP.NET C#生成静态页面时老是写不好变量! 急!
用ASP.NET C#生成静态页面时老是写不好变量! 急!
HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
要求在
//生成静态页开始
string htmlstring;
htmlstring =" <!DOCTYPE html PUBLIC ";
htmlstring += """;
htmlstring += "-//W3C//DTD XHTML 1.0 Transitional//EN"+"""';
htmlstring += " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
htmlstring += ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">";
htmlstring += "<HTML xmlns='http://www.w3.org/1999/xhtml'><HEAD><TITLE></TITLE>";
htmlstring += "<META content=text/html; charset=utf-8 http-equiv=Content-Type>";
htmlstring += "<link rel='stylesheet' href='viewworklog.css' type='text/css' />";
htmlstring += "</HEAD>";
htmlstring += "<BODY>";
htmlstring += " <DIV class=main>";
htmlstring += " <DIV class=titlecontmain>";
htmlstring += " <DIV class=title1><SPAN>";
htmlstring += txttitle.Text;
htmlstring += " </SPAN></DIV>";
htmlstring += "<DIV class=titlecont>";
htmlstring += "<P>";
htmlstring += WE_NewsContent.Text;
htmlstring += "</P></DIV></DIV></DIV></BODY></HTML>";
前面的那一句老是无法写对啊!!!! 急死了。请高手帮忙,谢谢!
------解决方案--------------------
这种最好使用StringBuilder
string htmlstring;
htmlstring =" <!DOCTYPE html PUBLIC ";
htmlstring += "\"";
htmlstring += "-//W3C//DTD XHTML 1.0 Transitional//EN\"";
htmlstring += "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
htmlstring += "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">";
\"转义
------解决方案--------------------
或者
htmlstring =" <!DOCTYPE html PUBLIC ";
htmlstring += @"""";
htmlstring += @"-//W3C//DTD XHTML 1.0 Transitional//EN""";
htmlstring += @"""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">";
htmlstring += @"""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">";
最好都使用单引号