【问题标题】:How to write function for onclick in mvc 2 application如何在 mvc 2 应用程序中为 onclick 编写函数
【发布时间】:2012-01-06 09:42:08
【问题描述】:

请帮助我...我不知道如何为按钮编写事件。我将按钮放在我创建的 mvc 2 aspx 文件中。
我想编写函数在单击按钮时做一些事情。

【问题讨论】:

  • 对不起我的语言。如果我在发布问题或回答问题时做错了,请通知错误。我是这个 stackoverflow 的新手,也是 asp.net 的新手。

标签: model-view-controller


【解决方案1】:
[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;
        }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-06-21
    • 1970-01-01
    • 2022-01-12
    • 2023-03-19
    • 2019-11-09
    • 2016-06-14
    • 1970-01-01
    • 2021-03-06
    相关资源
    最近更新 更多