任何人都可以告诉我们如何使用Url.action()传递动态值.
就像是,
var firstname="abc";
var username = "abcd";
location.href = '@Html.Raw(@Url.Action("Display", "Customer", new { uname = firstname ,name = username}))';
Run Code Online (Sandbox Code Playgroud)
firstname,在Url.action()方法中没有得到用户名.
如何使用Url.action()传递这些动态值?
我有一个sql select语句,其中包含一些从其他列或表计算的列.我使用As关键字为此列命名.
现在,我想通过计算列对此表进行排序.我不能使用该名称进行排序.
有人请帮助使用计算列对sql表进行排序.
我正在调用一个控制器方法,使用Url.action,
location.href = '@Url.Action("Display", "Customer", new { username = "abc",name = "abcdef",country = "India",email = "abc@hmail.com",phone = "9456974545"})';
Run Code Online (Sandbox Code Playgroud)
我的控制器方法是,
public void Display(string username, string name, string country, string email, string phone)
{ }
Run Code Online (Sandbox Code Playgroud)
在这个方法中,我只能得到第一个参数(username)的值.它没有获得传递的其他参数值.所有其他值均为null.
请建议我,什么错?
我从Jquery ajax调用MVC控制器方法.
$(document).ready(function () {
$.ajax({
type: "POST",
url: "/Customer/GetDetails",
contentType: "application/json; charset=utf-8",
async: false,
cache: false,
success: function (data) {
$.each(data, function (index, value) {
alert(value);
});
}
});
});
Run Code Online (Sandbox Code Playgroud)
我有一个名为Customer的实体.
Controller Method从DB中获取记录并存储为Customer of List,并以JsonResult类型返回该列表.
public JsonResult GetDetails()
{
CustomerDAL customer = new CustomerDAL();
IList<Customer> custList = customer.GetDetail();
return Json(custList);
}
Run Code Online (Sandbox Code Playgroud)
但是我的ajax的成功功能根本就不在这里.
asp.net-mvc ×3
c# ×2
javascript ×2
asp.net ×1
asp.net-core ×1
controller ×1
jquery ×1
sorting ×1
sql-server ×1
url.action ×1