Html 向 href 链接添加参数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47091805/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
adding a parameter to href link
提问by Iria
I need to send the user to another webpage but setting up parameters, I am using the QueryString in that page for that. This is my code:
我需要将用户发送到另一个网页,但要设置参数,为此我在该页面中使用了 QueryString。这是我的代码:
<a href= "school_info.aspx?edit_school=true&school=" + SchoolId>School Profile</a>
SchoolId is a parameter that I need to add, I have tried .ToString()
and it does not work, any help?
SchoolId 是我需要添加的参数,我试过了.ToString()
,但不起作用,有什么帮助吗?
The parameter is defined in the aspx.cs code
参数在aspx.cs代码中定义
采纳答案by Gowtham Shiva
You can do it this way,
你可以这样做,
function func(){
var SchoolId = 0;
window.location.href = "school_info.aspx?edit_school=true&school=" + SchoolId;
}
<!DOCTYPE html>
<html>
<body>
<a onclick="func();">Click Here</a>
</body>
</html>
That is, calling the href tag from the javascript after manipulating the href link.
即,在操作 href 链接后从 javascript 中调用 href 标签。
回答by Abdallah Nasser
You Can Use This
你可以使用这个
<a href="/order/[email protected]">@Model.OrderCode</a>
</p>
So Your parameter should be string , you can convert it to int or something else.
所以你的参数应该是 string ,你可以将它转换为 int 或其他东西。