I want to pass \'#\' to the query string like ?page.aspx?someParam=1234#5
.
URL-encode the sharp character: %23
.
try using escape(url parameter value) method in url instead of only parameter value
Please use Server.UrlEncode
on your querystring that will parse the '#' for you
Try using %23
. This is the url encoded value for #
.
The best way to pass #
, &
and other special characters without causing problems in asp.net query string is to use Server.UrlEncode()
See the following example.
private void btnSubmit_Click(object sender, System.EventArgs e)
{
Response.Redirect("page.Aspx?"+"someParam="+Server.UrlEncode("1234#5"));
}
or use %23
replacing #
but I think the more suitable way is using Server.UrlEncode()
so you can use other special characters without any problem.