需要可折叠内容(C#)的协助 [英] Need Assistance with Collapsible Content (C#)

查看:94
本文介绍了需要可折叠内容(C#)的协助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我有一个存储新闻和事件的网页(使用C#).数据(新闻和事件)按月份分类.当用户访问页面时,我只想显示现有月份的内容.例如,用户将看到.

八月
事件1
新闻2
七月
六月五月
四月

我希望用户能够单击任何其他月份来显示相应月份的内容.理想情况下,一次只能扩展一个月(但这不是必须的).

任何帮助或帮助将不胜感激.如果您需要更多信息,请告诉我.

谢谢您,

Allison

Hello,

I have a web page (in C#) that stores news and events. The data (news and events) is categorized by month. When the user visits the page, I would like to display the content of the existing month only. For example, the user will see.

August
event 1
news 2

July
June
May
April

I would like the user to be able to click on any other month to display the content of that respective month. Ideally, only one month should be expanded at a time (however this is not imperative).

Any help or assistance would be appreciated. If you need more information please let me know.

Thank you,

Allison

推荐答案

为什么不使用Javascript显示/隐藏内容.

假设您使用了以下html代码块:

why dont you use Javascript to display / hide content.

Say you have used the html code block as below :

<div onclick="javascript:expandCollapsePane(this, ''dvContainer'');"><br />August<br /></div><br /><div id="dvContainer"><br />Event 1 <br />News 2<br /></div>




现在,当用户单击名为august的Div窗格时,可以使容器div可见是对还是错:




Now when user clicks on the Div Pane named august you can make the container div visible true or false :

function expandCollapsePane(obj, pane) {<br />   var containerPane = document.getElementByID(pane);<br />   var isCollapsed = (containerPane.style.display == ''none'');<br />   if (isCollapsed) {<br />      containerPane.style.display = ''block'';<br />   }<br />   else {<br />      containerPane.style.display = ''none'';<br />   }<br />}



JavaScript仅在单击时隐藏dvContainer.要使所有这些元素在打开时不可见,只需创建一个数组,其中包含您创建的所有此类元素,然后在展开其中的任何一个元素之前,先进行for循环,然后将每个其他元素隐藏在该块中.

希望您能理解. [竖起大拇指] [玫瑰]



The javascript just hides the dvContainer on click. To make all of them invisible when one is open, just create an array of all such elements you create and before expanding anyone of them do a for loop and hide each other element in the block.

Hope you understand. [thumbs up][Rose]


这篇关于需要可折叠内容(C#)的协助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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