gpt4 book ai didi

c# - 客户端脚本无需查询字符串即可工作

转载 作者:行者123 更新时间:2023-11-28 01:07:53 24 4
gpt4 key购买 nike

此客户端脚本在没有查询字符串的情况下工作,但不显示查询字符串

ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('POSTED SUCCESSFULLY');document.location.href='/Group.aspx?grp_id='"+ Group_ID.Value +"'&grp_name='"+ Group_Name.Value +"'';", true);

最佳答案

现在您的代码将输出类似于以下内容的 js 代码:

alert('POSTED SUCCESSFULLY');document.location.href='/Group.aspx?grp_id='1'&grp_name='yourgroupname'';

其中存在一些语法错误。将其更改为没有不必要的单引号和 UrlEncode Group_IDGroup_Name 的值,因此它们是 url 友好的(可能不是必需的,但我建议这样做):

"alert('POSTED SUCCESSFULLY');document.location.href='/Group.aspx?grp_id="+ HttpServerUtility.UrlEncode(Group_ID.Value) +"&grp_name="+ HttpServerUtility.UrlEncode(Group_Name.Value) +"';"

关于c# - 客户端脚本无需查询字符串即可工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24853038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com