如何在mvc 2应用程序中编写onclick函数

时间:2012-01-06 09:42:09

标签: model-view-controller

请帮帮我......我不知道怎么写按钮的事件。我将按钮放在我创建的mvc 2 aspx文件中。我想在单击按钮时编写函数来做某事。

1 个答案:

答案 0 :(得分:0)

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult EvaluvateStudent(FormCollection collection)
        {
            Model.StudentModels studentDetail = new Model.StudentModels();
            studentDetail.Name = collection["Name"];
            studentDetail.RegNo = Convert.ToInt32(collection["RegNo"]);
            studentDetail.Tamil = Convert.ToSingle(collection["Tamil"]);
            studentDetail.English = Convert.ToSingle(collection["English"]);
            studentDetail.Total = CalculateTotal(studentDetail.Tamil, studentDetail.English);
            ViewData["Total"] = studentDetail.Total;
            return View("Student");
        }
        public float CalculateTotal(float tamil,float english)
        {
            float total = tamil + english;
            return total;
        }