Question

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 ""
Was it helpful?

Solution

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

OTHER TIPS

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?

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")
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top