【发布时间】:2022-01-14 16:46:42
【问题描述】:
我有字符串 list_name,我希望 href 链接文本是 list_name 中的字符串,而不是单词 list_name。我该怎么做?
public void ShowButtonLists(DataTable table, int length)
{
for (int i = 0; i < length; i++)
{
string list_name = table.Rows[i].ToString();
Response.Write("<td> <a href='ShowList.aspx?listname=" + list_name + "'>list_name</a></td> ");
Response.Write("<br/>");
}
}
【问题讨论】:
-
只记录开始/结束引号... listname='" + list_name + "'>" + list_name + "...
-
也可以考虑利用字符串插值。引号不再是一个问题,并且在编码时读起来更好