使用链接和锚点在ASP.NET中切换可见性的最佳方式是什么?

时间:2022-01-14 21:15:37

I have a page which is used to display numerous forms for the user to fill out and get reports generated. Each of these forms is inside it's own ASP:Panel control so that I can toggle the visibility of the form (so that only those with appropriate permissions get access to the reports they are allowed to).

我有一个页面,用于显示大量表单,供用户填写并生成报告。每个窗体都位于它自己的ASP:Panel控件中,这样我就可以切换窗体的可见性(这样只有具有适当权限的窗体才能访问允许它们访问的报表)。

The client has now requested a "table of contents" like area on the page with hyperlinks pointing to each of the forms (so that they don't have to spend time scrolling the page to find the particular report form they want). This is easy to accomplish using standard <a href="#Area"> and <a id="Area"> tags. What I am now looking for is a way that would allow me to hide the links of reports that the user does not have access to.

客户端现在请求了一个“目录”,比如页面上的区域,其中有指向每个表单的超链接(这样他们就不用花时间在页面上滚动才能找到他们想要的特定报表)。使用标准标签很容易实现。我现在正在寻找的是一种可以隐藏用户无法访问的报告链接的方法。

I was first thinking of using the ASP:LinkButton control, but I do not want any postbacks to occur from clicking the links (that would be very unnecessary). Are there any other methods I could use to accomplish the same goal? I am looking for something which would make it easy for me to toggle the visibility of the corresponding link at the same time I am toggling the visibility of the panels containing the report forms (done now from the code-behind).

我首先想到的是使用ASP:LinkButton控件,但是我不希望在单击链接时出现任何回发(这是非常不必要的)。有没有其他方法可以让我实现同样的目标?我正在寻找一些能够使我能够轻松切换相应链接的可见性的东西,同时我还在切换包含报表的面板的可见性(现在从代码后面完成)。

Note: Using VB as the language

注意:使用VB作为语言

2 个解决方案

#1


3  

If you use link controls you can just show or hide the link bases on the visibility of its related panel.

如果您使用链接控件,您可以显示或隐藏链接基于其相关面板的可见性。

Link1.Visible = Panel1.Visible

#2


0  

I was first thinking of using the ASP:LinkButton control, but I do not want any postbacks to occur from clicking the links (that would be very unnecessary)

我最初考虑使用ASP:LinkButton控件,但是我不希望在单击链接时出现任何回发(这是非常不必要的)

I disagree. You're talking about redrawing most of the page each time a link is clicked, making a full postback appropriate from a technical standpoint. Additionally, users are conditioned to expect a round-trip to the server when they click on links. That's what a hyperlink normally does. So it's also appropriate from a user-experience standpoint.

我不同意。在每次单击链接时,您都在讨论重新绘制大多数页面,从技术的角度进行完整的回发。此外,当用户点击链接时,他们习惯于期望返回服务器。超级链接通常就是这么做的。所以从用户体验的角度来看也是合适的。

#1


3  

If you use link controls you can just show or hide the link bases on the visibility of its related panel.

如果您使用链接控件,您可以显示或隐藏链接基于其相关面板的可见性。

Link1.Visible = Panel1.Visible

#2


0  

I was first thinking of using the ASP:LinkButton control, but I do not want any postbacks to occur from clicking the links (that would be very unnecessary)

我最初考虑使用ASP:LinkButton控件,但是我不希望在单击链接时出现任何回发(这是非常不必要的)

I disagree. You're talking about redrawing most of the page each time a link is clicked, making a full postback appropriate from a technical standpoint. Additionally, users are conditioned to expect a round-trip to the server when they click on links. That's what a hyperlink normally does. So it's also appropriate from a user-experience standpoint.

我不同意。在每次单击链接时,您都在讨论重新绘制大多数页面,从技术的角度进行完整的回发。此外,当用户点击链接时,他们习惯于期望返回服务器。超级链接通常就是这么做的。所以从用户体验的角度来看也是合适的。