Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

JavaScript - How to Pass Ampersand in Querystring Value in Asp.net

Mar 26, 2014
Introduction

Here I will explain how to send ampersand in querystring value in JavaScript using asp.net or passing ampersand in query string JavaScript or
jQuery.

Description:
  
In previous articles I explained jQuery check if string contains special characters or not, jQuery hide or show password characters,
jQuery expand textbox on focus, jQuery disable right click on image and many articles related to jQuery, JavaScript. Now I will explain how to send ampersand value in querystring using JavaScript in asp.net.

Generally ampersand ‘&’ will work as separator between value pairs like as shown below


http://aspdotnet-suresh.com?name=srvinfo&userid=231

Here if name contains ampersand & like “S&R Info” we need to encode & as %26 or we can pass url parameter with Server.UrlEncode() like as shown below


<script type="text/javascript">
var str = "http://aspdotnet-suresh.com?name= Server.UrlEncode(S&R Info)&userid=231"
</script>
                                                  OR

<script type="text/javascript">
var str = "http://aspdotnet-suresh.com?name= S%26R Info&userid=231"
</script>

I hope it helps you….Happy coding

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email
© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.