28 March 2017

How To Pass Querystring From One Page to Another Using JavaScript

I used to pass QueryString from one ASP.NET page to another using Hyperlink control. But since I had a requirement to pass the Querystring using pure JavaScript, I used the following code:

<script type="text/javascript">
        $(function () {
            $("#btnSend").bind("click", function () {
                var url = "SecondPage.aspx?name=" + encodeURIComponent($("#txtInput").val());
                window.location.href = url;
            });
        });
</script>


Enter string message: <input type="text" id="txtInput"/>
<input type="button" id="btnSend" value="Submit" />



No comments:

Post a Comment