C# 在ASP.NET中访问资源文件内容
我在Resource1.resx中有一个HTML文件。现在,我必须通过StreamReader使用html文件内容。我该怎么办 以下是html文件的内容:C# 在ASP.NET中访问资源文件内容,c#,html,asp.net,.net,C#,Html,Asp.net,.net,我在Resource1.resx中有一个HTML文件。现在,我必须通过StreamReader使用html文件内容。我该怎么办 以下是html文件的内容: <html> <body> <table> <tr> <td>$$name$$</td> </tr> <tr> <td>$$subject$$</td> </tr>
<html>
<body>
<table>
<tr>
<td>$$name$$</td>
</tr>
<tr>
<td>$$subject$$</td>
</tr>
</table>
</body>
</html>
但流返回null 嘿,谢谢大家的帮助,但我找到了解决办法。代码如下:
var assembly = Assembly.GetExecutingAssembly();
string resourceName = (string)HttpContext.GetGlobalResourceObject("Resource1", "MyTemplate");
string mystring = "";
mystring = resourceName;
mystring = mystring.Replace("$$Member$$", name);
mystring = mystring.Replace("$$Subject$$", TxtSubject.Text);
return mystring;
我认为如果你真的在资源文件中持有HTML,你应该考虑使用USER控件。是时候离开这样一个新概念了。结账这个安静的老,但会给ideo的working@AmitRanjan谢谢你的回复。但我必须这样使用它,因为这是要求。如果您对此有答案,请帮助我。谢谢。请跟随此链接。@qamar我跟随您的链接,使用后我从流中获取空值。我还编辑了我的代码。。。
var assembly = Assembly.GetExecutingAssembly();
string resourceName = (string)HttpContext.GetGlobalResourceObject("Resource1", "MyTemplate");
string mystring = "";
mystring = resourceName;
mystring = mystring.Replace("$$Member$$", name);
mystring = mystring.Replace("$$Subject$$", TxtSubject.Text);
return mystring;