c# - How to add Querystring parameter from Code behind using javascript in asp.net? - Stack Overflow

I am opening a page onClick event using javascript from code behind. But i want to pass querystring par

I am opening a page onClick event using javascript from code behind. But i want to pass querystring parameter and access it on another page.

string id=1;
    teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'");

The above code works fine!

Now i want to append QueryString using Javascript and Access it on another page from CodeBehind.

I Tried :

teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");

but it does'nt work!

How to Conditional Redirect using HTML Anchor:

 <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>

In above I want to set conditional Redirect depending on Querystring Parameter?

Eg: if isabout=true then redirect to TeamMember.aspx else Other.aspx Help Appreciated! Thanks

I am opening a page onClick event using javascript from code behind. But i want to pass querystring parameter and access it on another page.

string id=1;
    teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'");

The above code works fine!

Now i want to append QueryString using Javascript and Access it on another page from CodeBehind.

I Tried :

teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");

but it does'nt work!

How to Conditional Redirect using HTML Anchor:

 <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>

In above I want to set conditional Redirect depending on Querystring Parameter?

Eg: if isabout=true then redirect to TeamMember.aspx else Other.aspx Help Appreciated! Thanks

Share Improve this question edited Mar 28, 2013 at 6:28 SHEKHAR SHETE asked Mar 28, 2013 at 6:06 SHEKHAR SHETESHEKHAR SHETE 6,07415 gold badges88 silver badges144 bronze badges 2
  • ek number shekhar bhau. changla prashna aahe. – Freelancer Commented Mar 28, 2013 at 6:13
  • you need to wrap ID with single quotes. – muhammad kashif Commented Mar 28, 2013 at 6:33
Add a ment  | 

1 Answer 1

Reset to default 5

You have a single quote ' within the query string. You have to change the location of the quote ' to the end of the href string.

change this.

teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "'" + "&isabout=true");

To this.

teammember.Attributes.Add("onclick", "window.location.href='TeamMemberDetails.aspx?Id=" + Id + "&isabout=true'");

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745349217a4623724.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信