其中这些方法是显示在ASP.NET /隐藏行的正确方法是什么? [英] Which of these methods is the correct way to show/hide rows in ASP.NET?

查看:100
本文介绍了其中这些方法是显示在ASP.NET /隐藏行的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

多年来,必须有一打的方式来显示/隐藏的行或显示/隐藏页节到客户端ASP.NET服务器上或通过客户端的方法,如JavaScript和我收到就做什么丢失。下面是一些我所用的方法:

Over the years there must be a dozen ways to show/hide rows or showing/hiding page sections to the client in ASP.NET on the server or through client side methods like JavaScript and I am getting lost on what to do. Here are several of the ways I have used:


  • ASP.NET表,用真。可见/对行服务器端假

  • ASP.NET多视图 - 全有或全无这种控制,使每一行必须是一个MV。更多的是corase晶选项海事组织。

  • HTML表设置为=服务器直接或通过添加CSS属性,如maipulate。可见真/对行服务器端假要么标签: Me.tr1.Attributes(类) =ShowRows

  • HTML表格用CSS来显示/隐藏和客户端的JavaScript显示行。获取更复杂一点,当服务器端的结果决定何时显示JS /隐藏回客户端。

  • Ajax控件工具包控制像手风琴或CollapsiblePanel。

  • 的jQuery与.find()来获取到正确的,然后.show()

......,也许很多很多。大多数的服务器端的操作决定为我的时间至少当在UI显示/隐藏行,所以我通常向服务器端选项瘦,但我希望得到一些投入去哪家这些方法之一是大多数有利的,为什么这样我就可以更consistient在我的方式这样做。

...and probably many, many more. Most of the time a server-side action dictates for me at least when to show/hide rows in the UI, so I typically lean toward the server side options, but I want to get some input as to which one of these methods is most advantageous and why so I can be more consistient in my approach to doing this.

谢谢!

推荐答案

这取决于你的隐藏/显示的字段做什么。

It depends on what you're doing with the hidden/shown fields.

决定是否使用服务器或客户端时,请考虑以下内容:

Consider the following when deciding whether to use server or client side:


  • 隐藏控制服务器端从不给客户,所以他们的值不会公布。

  • 显示/隐藏服务器端
  • 控制需要一个回切换自己的知名度。

  • 控制隐藏客户端让你无后显示/隐藏回来。

如果你正在做别的什么也不改变CSS类服务器端,有没有必要为东西,可以很容易做到客户端的往返。

If you're doing nothing else but changing a css class server side, there's no need for a round trip for something that could easily be done client side.

如何切换客户端作出决定时考虑以下内容:

Consider the following when deciding on how to toggle client side:


  • 如果您已经使用jQuery jQuery的显示/隐藏/切换方法是巨大的。

  • Ajax控件工具包控件,如果你想有一个简单的方法来显示/隐藏是巨大的。但是,如果您已经使用jQuery,有没有点。

  • 切换CSS类(如类=隐藏)是很容易与香草javacript做。

  • jQuery show/hide/toggle methods are great if your are already using jQuery.
  • Ajax Control Toolkit controls are great if you want a simple way to show/hide. But if you are already using jQuery, there's no point.
  • Toggling css classes (e.g. class="hidden") is very easy to do with vanilla javacript.

但最终它归结为你想在特定的场景与您的控件做什么。有每一种情况没有明确的答案。

But ultimately it comes down to what you want to do with your controls in your particular scenario. There is no definitive answer for every situation.

这篇关于其中这些方法是显示在ASP.NET /隐藏行的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆