我想在查询字符串中设置变量,例如
new XAttribute("onclick", "javascript:document.location.href='/Controller/Action
?a=Va&b=Vb&c=Vc';"),
这里 Va、Vb 和 Vc 是变量。但如果我这样写,那么在单击按钮时,它不会传递 Va、Vb 和 Vc 值,而是将它们作为字符串传递。
最佳答案
您必须退出引号才能引用该变量。
new XAttribute("onclick", "javascript:document.location.href='/Controller/Action
?a=" + Va + "&b=" + Vb + "&c=" + Vc+ "';"),
关于c# - 如何设置查询字符串中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11742442/