Hi I am trying to call an action result in my controller containing parameters, but whenever one of these parameter contains # sign(special character) the string parameters does not include # sing in parameter and Next all parameters are set to null.
Following is my java script through which i am calling my action result.
<script type="text/javascript">
$(document).ready(function () {
$('#btnExport').unbind().click(function () {
var url = @Url.Content("~/BankStatement/ExportBankStatementSummary") +
"?legalName=" + '@ViewBag.LegalName' +
"&dba=" + '@ViewBag.DBA' +
"&contactPerson=" + '@ViewBag.ContactPerson' +
"&address=" + '@ViewBag.Address' +
"&period=" + '@ViewBag.Period' +
"&totalHeading=" + '@ViewBag.TotalHeading';
window.location = url;
});
});
</script>
This is the action result that is called in this java script
public ActionResult ExportBankStatementSummary(string legalName, string dba,
string contactPerson, string address,
string period, string totalHeading)
{
ViewBag.LegalName = legalName;
ViewBag.DBA = dba;
ViewBag.ContactPerson = contactPerson;
ViewBag.Address = address;
ViewBag.Period = period;
ViewBag.TotalHeading = totalHeading;
...
The problem is that in the action result parameters, when ever any of the parameter contains any special character (# in this case) then that parameter and next parameters becomes null.
For example if address is "Street # 2" then parameter address becomes "Street " and next parameters period and totalHeading becomes null.
Any help will be highly appreciated.
Thanks in advance.
[I do not agree on the duplication of this question because the marked duplicate question was discussed in detail and the detailed conversation covered the answer of this question but the actual question was totally different from this question.]