如何在Controller中創建一個方法,使其成爲AJAX Callable?如何在MVC控制器中創建一個方法,使其成爲AJAX Callable?
例如,代碼爲{0}可以使用訪問{1}時返回類型是的ActionResult:
{0}:
public ActionResult TestWithActionResult(string id)
{
return View();
}
{1}:
http://localhost:4574/ControllerName/TestWithActionResult/2
但我的下面的代碼{3}不能與{4}訪問:
{3}:
public string TestWithString(string id)
{
return "some string";
}
{4}:
http://localhost:4574/ControllerName/TestWithString/2
當我打開{4}時,{3}中的ID始終爲空。
我應該用不同的方式裝飾{3}嗎?怎麼樣?
感謝,
你會如何使用AJAX從客戶端調用它? – 2012-02-08 15:35:51
你會如何用@ Html.RenderAction(「TestWithActionResult」)來調用它?你需要傳遞參數給它。 – 2012-02-08 17:27:31