的操作方法中缺少URL參數值我想將textarea值和其他一些參數傳遞給action方法。所以我用以下方式使用jquery。ASP.Net MVC
查看: -
@Html.TextArea("aboutme")
<a id="@Profile.Id" title="@Profile.name" onclick="SubmitProfile(this)" >
Submit</a>
jQuery的方法: -
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);
}
操作方法: -
public ActionResult ActionMethod(string id,string name,string aboutme)
{
//
}
上面的代碼工作沒錯,但是當有任何一個參數值包含的空格就在其中。在Jquery方法中,URL看起來很好。但在操作方法中,它將值修剪至第一個空格,其餘參數爲空。
讓我有一些例子
讓說的id = '123',名稱= 'amith町' 解釋,aboutme = '我是軟件ENGG'
網址jQuery的方法
url='http://localhost/Controller/ActionMethod?id=123&name=amith cho ,aboutme=i am software engg'
但越來越行動方法id=123
name=amith
aboutme=null
如何解決這個問題?
使用此URL發送數據到行動'的http://本地主機/控制器/ ActionMethod ID = 123&名稱= amith町aboutme =我是軟件engg'是** **壞,壞* * '壞'練習......改爲發佈這些值。 – Yasser