Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
On HomeController i have called a view (with a button), on click on this button i want to call another controller which will return a another view. i am beginner in mvc.


As in asp.net button_click function is called on click event of button.where i redirect to another page.
Posted

what i understand that you want to create a link in your page to navigate to another page :

<a href="/Home/Page2" role="button">Go to Index</a>
<button  role="button" onclick="window.location.href= '/Home/Page2';">Go to Index</button>

In HomeController you must write :
C#
public ActionResult Page2()
    {
        return View();
    }

and In Views/Home folder :
you must create Page2 view

I hope that the good answer.
 
Share this answer
 
You can directly return a different view like:

C#
return View("NameOfView", Model);


Or you can make a partial view and can return like:

C#
return PartialView("PartialViewName", Model);



Reference: http://stackoverflow.com/questions/[^]
 
Share this answer
 
Comments
manish-gusain8909 18-Dec-15 7:54am    
i want to know code for view(button,hyperlink etc) from where i want to call a controller. what to write in onclick ,textchange etc to call a controller.where i can perform some task. i don't in jquery . i want to learn basic.

<button >
<textbox>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900