Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8670815
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:47:48+00:00 2026-06-12T18:47:48+00:00

I want to call a controller when click the button in view.How can I

  • 0

I want to call a controller when click the button in view.How can I do it in MVC?.

This is my first controller.

public ActionResult DetailForm()
{
    graduandModel model = new graduandModel();

    var ceremonyList = _ceremonyService.GetAllCeremonyByDate(DateTime.Now);

    if (ceremonyList.Count == 0)
    {
        return Content("No ceremony can be loaded");
    }
    else
    {
        foreach (var c in ceremonyList)
        {
            model.AvailableCeremony.Add(new SelectListItem() { 
                Text = "Ceremony at " + c.ceremony_date.ToString(), 
                Value = c.ceremony_id.ToString() });
        }
        return View(model);
    }               
}

This is my view.

@{
    Layout = "~/Views/Shared/_ColumnsThree.cshtml";
}

@model graduandModel
@using Nop.Web.Models.Hire;
@using Nop.Web.Framework;
@using Telerik.Web.Mvc.UI;
@using System.Linq;

<table>
    <tr>
        <td>
            @Html.LabelFor(model => model.ceremony_id)
        </td>
        <td>
            @Html.DropDownListFor(model => model.ceremony_id, Model.AvailableCeremony)
        </td>
    </tr>
    <tr>
        <td>
            @Html.LabelFor(model => model.first_name):
        </td>
        <td>
            @Html.EditorFor(model => model.first_name)       
        </td>
    </tr>  
    <tr>
        <td>
            @Html.LabelFor(model => model.middle_name):
        </td>
        <td>
            @Html.EditorFor(model => model.middle_name)
        </td> 
    </tr>
    <tr>
        <td>
            @Html.LabelFor(model => model.last_name):
        </td>
        <td >
            @Html.EditorFor(model => model.last_name)
        </td>
    </tr>
    <tr>
        <td>
            @Html.LabelFor(model => model.student_id):
        </td>
        <td>
            @Html.EditorFor(model => model.student_id)  
        </td>
    </tr>    
    <tr>
        <td colspan="2" class="buttons">
            <input type="submit" id="btnsearchgraduand" name="btnsearch" 
                class="searchbutton" value="@T("Search")" />
        </td>
    </tr>
</table>

Then When I click the search button I want to check the input data.
Should I write new controller like this

public ActionResult CheckDegreeDetails()
{
    graduandModel model = new graduandModel();

    var degreeList = _graduandService.GetGraduandByStudent(
        model.ceremony_id, model.first_name, 
        model.middle_name, model.last_name);
    return View(model);
}

Or…

I don’t know how to call controller when click the button…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:47:49+00:00Added an answer on June 12, 2026 at 6:47 pm

    You want to wrap your user input fields and the submit button in a form. You can use an html helper that will also let you specify the controller action to call.
    So modify your view:

    ...
    @model graduandModel
    @using Nop.Web.Models.Hire;
    @using Nop.Web.Framework;
    @using Telerik.Web.Mvc.UI;
    @using System.Linq;
    
    @using(Html.BeginForm("DetailForm", "ControllerName", FormMethod.Post, new {enctype="multipart/form-data"})
    {
    <table  >
    
     <tr>
        <td >
            @Html.LabelFor(model => model.ceremony_id)
        </td>
    ...
    
    //code omitted for brevity
    
    ...
    
    <input type="submit" id="btnsearchgraduand" name="btnsearch" class="searchbutton" value="@T("Search")" />
    
    })
    

    Then in your controller you need to add the method to ‘catch’ this form. You’re already using a strongly typed view so capturing the data is easy

    [HttpPost]
    public ActionResult DetailForm (graduandModel model)
    {
    //do what you need to do with the data here
    //the model passed into this method's parameter should 
    //contain all the data from the editor templates in the view
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to call a html page on click of a button in mvc.
I want to call a controller function from a view. Is that possible in
I want to call a sheet from within a view controller (user clicks on
I want to call my controller when users click backward and forward. But I
So I have an MVC Action in my controller public System.Web.Mvc.ActionResult Link(LinkType type) {
My Controller Action is: public ActionResult PVInPage() { return View(); } public ActionResult ViewPage2()
I want to call a method in the Web API controller on click of
I want to be able to click a button, have a function in my
I have a Action in controller as public ActionResult Download() { return File(FileStream, application/octet-stream,
I want to click the back button in the navigationBar programmatically in my second

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.