简体   繁体   English

如何动态更改页面模板

[英]How to Change a page template dynamically

I want to change the inner template of my page on some click event, but without changing the master layout. 我想在某些click事件上更改页面的内部模板,但不更改主版面。

The page contents are stored in Database.And each template is given an ID. 页面内容存储在数据库中,每个模板都有一个ID。

The issue is how to display the new template? 问题是如何显示新模板? Is this possible? 这可能吗? Any ideas or suggestions are welcome... 欢迎任何想法或建议...

Iam using MVC3. 我使用MVC3。 Can i use partial views as templates and load this view on ajax call ? 我可以使用部分视图作为模板并将其加载到ajax调用中吗?

without any more information about what's a template for you i can only tell you that you can use UpdatePanel or Ajax.Load function in order to dynamcly load a new part of the page. 没有关于模板的更多信息,我只能告诉您可以使用UpdatePanel或Ajax.Load函数动态加载页面的新部分。 (Or change the whole page without reload it). (或更改整个页面而不重新加载它)。

Partial view with ajax calls is the best solution for MVC3 razor template! 带有ajax调用的部分视图是MVC3剃刀模板的最佳解决方案! (eg : $('#container').load('_yourPartial.cshtml', '#right');) (例如:$('#container')。load('_ yourPartial.cshtml','#right');)

Sample : http://www.codemein.net/2012/05/how-to-refresh-partial-view-with-ajax-asp-net/ (not from me) 样本: http//www.codemein.net/2012/05/how-to-refresh-partial-view-with-ajax-asp-net/ (不是我的)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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