I wanted to pass textarea value and some other parameters to action method. so i did using the jquery in the following way.
View:-
@Html.TextArea("aboutme")
<a id="@Profile.Id" title="@Profile.name" onclick="SubmitProfile(this)" >
Submit</a>
Jquery Method:-
function SubmitReview(e,count) {
var Text = "'"+jQuery("#aboutme").val()+"'";
var url = 'http://' + window.location.host + '/Controller/ActionMethod?' + 'id=' + e.id + '&name=' + e.title + '&aboutme=' + Text;
jQuery("#Profile").load(url);
}
Action Method:-
public ActionResult ActionMethod(string id,string name,string aboutme)
{
//
}
Above code is working fine, but when ever any one of the parameter value contains spaces in it. In Jquery method URL looks fine.but in action method it trims the value upto 1st space and remaining parameters are null.
Let me explain with some example
let say id='123',name='amith cho' ,aboutme='i am software engg'
Url in Jquery method
url='http://localhost/Controller/ActionMethod?id=123&name=amith cho ,aboutme=i am software engg'
but it is getting in action method as id=123 name=amith aboutme=null
How to solve this?
http://localhost/Controller/ActionMethod?id=123&name=amith cho ,aboutme=i am software enggis a bad, bad,badpractice... POST these values instead.