My project structure is like:
Controllers/PartographController.cs
- Views/Partograph/Create.cshtml
Controllers/BirthDetailsController.cs
- Views/BirthDetails/Create.cshtml
Is it possible to display both create method from one controller?
Say for example I have a PartographController and a Partograph/Create.cshtml view. While in the PartographController, I can easily Create new partograph.
Now say I have a BirthDetailsController and a BirthDetails/Create.cshtml view also.
I want to show both create method from one controller but when the user input the different form and finally attempt to submit it then it effects the particular controller.
How can I do this? Is there a good way to do this?
Thanks in advance
CodePudding user response:
One of them is changing the post action URL with Javacript and direct the form to which controller you want. I don't know if this is a good solution for you but you can show and hide 2 different forms and post them seperately.
CodePudding user response:
You could try as below in your target controller:
[Route("Partograph/Create")]
public IActionResult Create1()
{
return View();
}
[Route("BirthDetails/Create")]
public IActionResult Create2()
{
return View();
}
Move the two view named "Create1"and "Create2" to the target floder