Base solution for your next web application
Open Closed

call a controller function from frontend view #3416


User avatar
0
avanekar02 created

Hello

how do i call a function from a view in frontend the funtion is defined in the controller as follows

using Abp.Domain.Uow;
using Samit.CmsProTest.School.Courses;
using Samit.CmsProTest.School.Courses.Dto;
using Samit.CmsProTest.Web.Models;
using Samit.CmsProTest.Web.Models.FeedBack;
using System.Web.Mvc;

namespace Samit.CmsProTest.Web.Controllers
{
    public class FeedBackController : CmsProTestControllerBase
    {
        private readonly ICourseDtlAppService _courseDtlAppService;

        public FeedBackController(ICourseDtlAppService courseDtlAppService)
        {
            _courseDtlAppService = courseDtlAppService;
        }

        public ActionResult Index(FeedBackViewModel feedbackViewModel)
        {

            var model = new FeedBackViewModel();

            return View(model);
        }


        public ActionResult FeedBack(FeedBackViewModel feedbackViewModel)
        {

            var model = new FeedBackViewModel();

            return View(model);
        }

    }
}

3 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    What you mean by "how do i call a function from a view"? If you explain in detail what you want to do and what is your scenario, then we can help better.

  • User Avatar
    0
    avanekar02 created

    ok i have created a view in the frontend called feedback and in the controller folder a feedback controller from the view feedback.cshtml i want to accept data and when i submit the form i want an action in the feedback controller to be called..

    Thanks Anwar

  • User Avatar
    0
    alirizaadiyahsi created

    If I understand you want to post data from view to action. So you can set your <form> element action attribute, something like following:

    <form action="FeedBack/FeedBack" ...