If I pass
const string strEditParams = "TaskID={0}&TaskName={1}";
string strEditValues = string.Format(strEditParams,
lbl.Text
, "$#hello"
);
lnkBtn.Attributes.Add("onClick", "return OpenEditTask('test.aspx?" + strEditValues + "')");
from page1.aspx to test.aspx, and in the page load of test.aspx if I do
if(!IsPostBack)
{
var pp = Request["TaskName"].ToString();
}
I get only $.
Why in query string i am getting only $ in this case and not the full values of “TaskName” (characters before #) # and how to overcome this?
Thanks
In URLs, the
#character introduces a fragment identifier. It has to be encoded to be used in the query string itself.You can either encode it yourself:
Or use HttpServerUtility.UrlEncode():