C# 如何在asp.net中使用javascript从代码隐藏中添加Querystring参数?
我正在使用代码隐藏中的javascript打开一个页面onClick事件。但我想传递querystring参数并在另一个页面上访问它 上面的代码工作正常 现在我想使用Javascript附加QueryString,并从CodeBehind的另一个页面访问它。 我试过:C# 如何在asp.net中使用javascript从代码隐藏中添加Querystring参数?,c#,javascript,asp.net,query-string,C#,Javascript,Asp.net,Query String,我正在使用代码隐藏中的javascript打开一个页面onClick事件。但我想传递querystring参数并在另一个页面上访问它 上面的代码工作正常 现在我想使用Javascript附加QueryString,并从CodeBehind的另一个页面访问它。 我试过: teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=
teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");
但它不起作用!
如何使用HTML锚定条件重定向:
<a style="border: 0px none; float: left;" href="TeamMember.aspx">
<img alt="<--" src="Images/ArrowLeft.png" style="display: inline-block; cursor: pointer;
border: 0 none;" />
</a>
在上面,我想根据Querystring参数设置条件重定向
例如:如果isbaout=true,则重定向到TeamMember.aspx else Other.aspx
谢谢你的帮助!
谢谢您在查询字符串中有一个引号
”
。您必须将引号“
的位置更改为href字符串的结尾
改变这个
teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");
对这个
teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "&isabout=true'");
谢谢回复!但这会导致Javascript错误:“未终止的字符串”!我修改了我的答案。。请再试一次。谢谢你的帮助!请你回答我的第二个问题,我已经在现有的修改?这取决于。。。检查在哪里进行?在哪一页?重定向应该是服务器端还是客户端?无论是服务器端还是客户端都可以,但应该可以正常工作。。!但仅使用Ancher标签:)plz…?ek编号shekhar bhau。changla prashna aahe.您需要用单引号将ID括起来。
teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "&isabout=true'");