给定内容页面上的代码:
Are you sure you want to add another <asp:Literal runat="server" id="Name1" /> to the basket?
You already have a <asp:Literal runat="server" id="Name2" /> in your basket.
<asp:Literal runat="server" id="Name3" /> has not yet been added to your basket.
然后在代码隐藏中:
Name1.Text = Product.Name;
Name2.Text = Product.Name;
Name3.Text = Product.Name;
我很确定这不是解决问题的最佳方法,是否有我不知道的 ASP.net 功能或设计模式?
最佳答案
为什么不用string.Format
?
String.Format("Are you sure you want to add another {0} to the basket? You already have a {0} in your basket. {0} has not yet been added to your basket.", Product.Name)
关于c# - ASP.net 有很多具有相同值的文字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7178364/