Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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
ek number shekhar bhau. changla prashna aahe. – Freelancer Mar 28 at 6:13
you need to wrap ID with single quotes. – muhammad kashif Mar 28 at 6:33

1 Answer

up vote 5 down vote accepted

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'");
share|improve this answer
thanks for reply! But this gives Javascript Error: "Unternminated String"! – SHEKHAR SHETE Mar 28 at 6:12
I've modified my answer .. pls try it again. – scartag Mar 28 at 6:13
Thanks this works! Will u please reply to my second question that i have modified in existing? – SHEKHAR SHETE Mar 28 at 6:32
It depends ... where is the check being done? on what page? is the redirect supposed to be server side or client side? – scartag Mar 28 at 6:35
either on server side or client side its ok but should work that set..!but using Ancher tag only :) plz...? – SHEKHAR SHETE Mar 28 at 6:38
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.