简体   繁体   中英

How to call a controller from a view

Im using MVC and Im having the following html code to get data from mssql.

In the following code it calls the DebitAndCreditNotesService and the function GetCheckoutRoomInfo

@Html.Partial("_InHouse", new DebitAndCreditNotesService().GetCheckoutRoomInfo())

But how can i modify the above code to call a controller and function it got. Suppose i got a controller and method for eg- CreditNoteController and the method is Inhouse

public class CreditNotesController : BaseController
{
public PartialViewResult InHouse()
        {

        }
}

How can i do this? Im still a beginner

I don't know your model structure, but;

public PartialViewResult InHouse()
{
CheckoutRoom model = new CheckoutRoom();
return View(model);
}

you can do it with a similar code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM