1

我有一个 div 需要隐藏到 10 月 12 日,然后从 10 月 13 日开始显示。该站点是用 C# .NET 构建的,因此我可以在 HTML 页面的代码隐藏中添加一个 if 语句。不确定这是否可行,或者我是否需要一个 jQuery 解决方案(我对此一无所知)。任何帮助,将不胜感激。

这是 HTML 中的代码:

<p style="bold">SHOW THROUGH 10/12!!!<p>
<p>Every day from now until Metastatic Breast Cancer Awareness Day (Oct. 13), a new video will be featured. Please check-in every day to hear a new story and come back on Oct. 13 to see the new, complete video wall.</p>

<div id="mbcRadioList">
    <p style="bold">BUILD BUT HIDE UNTIL 10/13!!!<p>
    <p><strong>Want to learn more?</strong> Select a video topic to better understand the varied experiences of people living with MBC and their family and friends.</p>
    <div class="checkBoxesColumn">
        <label><input name="videoWallRadio" type="radio" id="" value="" />View All</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" checked />My MBC Journey</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Challenges</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Positive Outlooks &amp; Advice</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Giving Thanks</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Family / Friend Perspective</label>
    </div>
</div>

<div id="mbcRadioList">如果有办法做到这一点,我在列表周围添加了一个句柄来控制代码隐藏。如果它是 jQuery 解决方案,我可以将其删除。

提前致谢!

4

1 回答 1

3

按照其他人的建议做:

1) 将 div 设置为runat="server"

2) 将 div 设置为visible="false"

3) 在Page_Load您的代码隐藏中,添加一个if检查日期的语句,然后更改visibletrue

aspx 标记:

<div id="mbcRadioList" runat="server" visible="false">
    <p style="bold">BUILD BUT HIDE UNTIL 10/13!!!<p>
    <p><strong>Want to learn more?</strong> Select a video topic to better understand the varied experiences of people living with MBC and their family and friends.</p>
    <div class="checkBoxesColumn">
        <label><input name="videoWallRadio" type="radio" id="" value="" />View All</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" checked />My MBC Journey</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Challenges</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Positive Outlooks &amp; Advice</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Giving Thanks</label>
        <label><input name="videoWallRadio" type="radio" id="" value="" />Family / Friend Perspective</label>
    </div>
</div>

代码隐藏:

protected void Page_Load(object sender, EventArgs e)
    {
        // ..... your other code

                    if(DateTime.Now >= new DateTime(2012, 10, 13) ){
                          mbcRadioList.Visible = true;
                    }
    }

正如其他人所建议的那样,如果需要,请确保考虑时区。

于 2012-09-17T16:14:52.120 回答