0

I have two different pages. I want to send querystring from one to another. below is my sample code that i have tried

window.location.search = 'id='+hidposid.value; 
window.location.href="editviewposition.aspx";

in another page i retrieve the value

cookie1 = HttpContext.Current.Request.QueryString("id") ' returns ""

3 Answers 3

3
<script type="text/javascript">
    $(function () {
        $("#btnQueryString").bind("click", function () {
            var url = "Page2.htm?name=" + encodeURIComponent($("#txtName").val()) + "&technology=" + encodeURIComponent($("#ddlTechnolgy").val());
            window.location.href = url;
        });
    });
</script>

<input type="button" id="btnQueryString" value="Send" />

Hope this will help u..

Sign up to request clarification or add additional context in comments.

Comments

1

I think I'd rather do something like

window.location.href= 'editviewposition.aspx?id=' + hidposid.value;

Or is there a reason this is not possible?

6 Comments

this is what i have tried before but its not working
are your sure there is a value in hidposid.value ?
The first line of code you show will add the id pramaeter to the current url and load that. So the current page will be loaded with that parameter. Thesecond line of code you show, will load the page "editviewposition.aspx" without any parameters. Actually you redirect twice, once to the current url with a parameter, once to the editviewposition.aspx without a parameter
what about the above u have given? will it pass the querystring
It'm quiet confident it should work that way. What is the url in your browser before HttpContext.Current.Request.QueryString("id") is hit?
|
0

Here you are passing query string not cookies Get it like

window.location.search = '?id='+hidposid.value;
window.location.href="editviewposition.aspx";

and then in code behind

HttpContext.Current.Request.QueryString("id")

4 Comments

Should be brackets IIRC. Also, you can point to the querystring explicitly: HttpContext.Current.Request.QueryString["id"]
Sorry i write it in VB
sorry, i have modified the question. still having problem
PLease add ? to search

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.