简体   繁体   English

ASP.NET内容显示

[英]ASP.NET content display

I am building a profile page in asp.net and it has two tabs(Horizontally), one for profile and one for settings. 我正在asp.net中建立一个配置文件页面,它有两个选项卡(水平),一个用于配置文件,一个用于设置。 If a user navigates between tabs, he will see the settings page and the profile page. 如果用户在选项卡之间导航,则将看到设置页面和配置文件页面。 I know two ways to implement this. 我知道两种实现方法。

  1. Code the page contents in the page and use javascript to hide them, while navigating through them. 对页面中的页面内容进行编码,并在浏览它们时使用javascript隐藏它们。 This type of method is inefficient as it will lead to performance issues and increase load time. 这种类型的方法效率低下,因为它将导致性能问题并增加加载时间。

  2. Use onclick event handler and build the page using codebehind file. 使用onclick事件处理程序并使用codebehind文件构建页面。 This is more efficient way, I can use javascript to rotate something to show that something is being processed and then call a last method in codebehind to hide the rotating Image. 这是一种更有效的方法,我可以使用javascript旋转某些内容以显示某些内容正在处理中,然后在代码隐藏中调用last方法隐藏旋转的图像。

Besides these methods, Are there some other efficient ways to accomplish this? 除了这些方法之外,还有其他有效的方法可以实现此目的吗?

The answer depends on many factors. 答案取决于许多因素。 Do you want the user to be able to switch back and forth without page refreshes? 您是否希望用户能够在不刷新页面的情况下来回切换? If so, then you have to load both tabs. 如果是这样,则必须加载两个选项卡。

If you're ok with partial refreshes, then you can use Ajax to populate the tabs when you click on them. 如果您可以部分刷新,则可以在单击选项卡时使用Ajax填充选项卡。 This has some performance consequences, since it needs to round trip to get the data. 这会带来一些性能后果,因为它需要往返来获取数据。

If you're ok with complete refreshes, then simply have each be a different page, when you click on the other tab, it just loads the other tab page. 如果您可以完全刷新,则只需将每个页面都放在不同的页面上,当您单击另一个选项卡时,它只会加载另一个选项卡页面。

I'm really not sure what you mean by "build the page with code-behind". 我真的不确定“用隐藏代码构建页面”是什么意思。 Perhaps you mean only include the html for the selected tab when the page is loaded. 也许您的意思是在页面加载时只为选定的选项卡包含html。 In my opinion, it's easier to simply make them different pages than to write complex code that changes the structure of the page. 我认为,简单地使它们成为不同的页面比编写更改页面结构的复杂代码要容易得多。

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

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