0

I am new to asp.net MVC and i am wondering how i would go about passing a date from a Jquery DateTime picker and pass it across to the controller then do some linq and return the new value to the page.

I have had a play around with @Html.BeginForm but with no joy.

ViewCode

 @Html.BeginForm("GetSigmaDateInfo", "HomeController", FormMethod.Post)
{
        <h3>Date :</h3>   <input type="text" id="dp" />
       <input type="submit" value="Update" />
       }

On the button click above i would like to retrieve data from a linq statement and return it to the page.

Controller Code

 [HttpPost]
    public ActionResult GetSigmaDateInfo(string Date)
    {
        string test = null;
        return View();

    }
4

2 回答 2

2

文本框应与参数同名.. 如下所示

public ActionResult GetSigmaDateInfo(string dp)

&

<input type="text" id="dp" name="dp" />

-

另外,从表单定义“Home”而不是“HomeController”中删除“controller”关键字

于 2013-09-17T10:12:28.493 回答
2

2 代码问题

  1. 永远不要输入控制器的完整名称,您只需要添加前缀即 Home
  2. 元素的名称必须与控制器中传递的参数名称相同

由于您是 MVC 新手,请阅读这篇文章 http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx

它给你想要的一切,告诉一切

于 2013-09-17T10:21:44.083 回答