C# C-将C变量传递给JavaScript
我有以下C代码行:C# C-将C变量传递给JavaScript,c#,javascript,string,C#,Javascript,String,我有以下C代码行: Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "window.open('http://localhost:4000/Transaction_Number.aspx?num=<%=trans_number%>', '_newtab')", true); 现在,trans_number是我的C代码中的一个变量。我的问题是,当我处理查询字符串num变量时,结果总是: <%trans_
Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "window.open('http://localhost:4000/Transaction_Number.aspx?num=<%=trans_number%>', '_newtab')", true);
现在,trans_number是我的C代码中的一个变量。我的问题是,当我处理查询字符串num变量时,结果总是:
<%trans_number%>
而不是该变量的内容。我如何解决这个问题?我想,你可以很容易地解决这个问题。。。也许:
Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "window.open('http://localhost:4000/Transaction_Number.aspx?num=" + trans_number + "', '_newtab')", true);
我想,你可以很容易地解决这个问题。。。也许:
Page.ClientScript.RegisterStartupScript(Page.GetType(), null, "window.open('http://localhost:4000/Transaction_Number.aspx?num=" + trans_number + "', '_newtab')", true);
您有一个字符串,该字符串与一个变量连接,然后又嵌入到另一个字符串中。当您使用中间变量和字符串时,这样的问题往往会消失。格式方法:
您有一个字符串,该字符串与一个变量连接,然后又嵌入到另一个字符串中。当您使用中间变量和字符串时,这样的问题往往会消失。格式方法: