如何从另一个视图调用视图。 [英] How to Call a view from another view.
问题描述
在HomeController上我调用了一个视图(带有一个按钮),点击这个按钮我想调用另一个控制器,它将返回另一个视图。我是mvc初学者。
在asp.net中,button_click函数在button的click事件上被调用。其中我重定向到另一个页面。
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.
推荐答案
您可以直接返回不同的视图,例如:
You can directly return a different view like:
return View("NameOfView", Model);
或者您可以进行部分查看并返回如下:
Or you can make a partial view and can return like:
return PartialView("PartialViewName", Model);
参考: http://stackoverflow.com/questions/ [ ^ ]
我理解你的意思想在页面中创建链接以导航到另一个页面:
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>
在HomeController中你必须写:
In HomeController you must write :
public ActionResult Page2()
{
return View();
}
和In Views / Home文件夹:
你必须创建 Page2 view
我希望得到好的答案。
and In Views/Home folder :
you must create Page2 view
I hope that the good answer.
这篇关于如何从另一个视图调用视图。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!