客户端脚本没有查询字符串

时间:2014-07-20 17:26:09

标签: c# javascript asp.net

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

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

1 个答案:

答案 0 :(得分:1)

现在您的代码将输出与此类似的js代码:

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

那里有一些语法错误。将其更改为没有必要的单引号和UrlEncode Group_IDGroup_Name的值,因此它们对网址友好(可能没有必要,但我建议它):< / p>

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