【问题标题】:Cursor type change dynamically光标类型动态变化
【发布时间】:2013-11-30 12:12:00
【问题描述】:

我正在处理一个动态加载游标类型的问题。

我的网站上有横幅。现在横幅与锚标签绑定。如果该横幅有链接,则光标类型应为Pointer,否则光标将为default。我正在使用中继器绑定横幅。而且我已经尝试在ItenBound 上做到这一点。但没有得到确切的结果。

protected void repeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
    DataRowView drv = (DataRowView)e.Item.DataItem;
    if (!drv["banner_url"].ToString().Equals(string.Empty))
    {
        ((HtmlAnchor)e.Item.FindControl("banner")).HRef = Convert.ToString(drv["banner_url"]);
        ((HtmlAnchor)e.Item.FindControl("banner")).Attributes.Add("url","yes");
        ((HtmlAnchor)e.Item.FindControl("banner")).Attributes.Add("style", "cursor:default;");
    }
    else
    {
        ((HtmlAnchor)e.Item.FindControl("banner")).HRef ="";
        ((HtmlAnchor)e.Item.FindControl("banner")).Attributes.Add("style", "cursor:pointer;");
        ((HtmlAnchor)e.Item.FindControl("banner")).Attributes.Add("url", "no");
    }
}

我的aspx页面代码是

 <asp:Repeater ID="rpt_primary" runat="server" OnItemDataBound="repeater_ItemDataBound">
            <ItemTemplate>
                <div class="ws_images">
                    <ul>
                        <li><a id="banner" runat="server">
                            <img id="wows1"  style="cursor:default;" width="770" height="327" runat="server" src='<%# "banner/"+ DataBinder.Eval(Container.DataItem,"banner_image") %>' 
                                alt="" />
                        </a></li>
                    </ul>
                </div>
            </ItemTemplate>
        </asp:Repeater>

【问题讨论】:

    标签: javascript asp.net repeater banner mouse-cursor


    【解决方案1】:

    定义一个CSS class,比如curcor_pointer,其中包含样式规则cursor:pointer !important;。 在repeater_ItemDataBound 处理程序中,只需设法添加和删除 css 类。 试试看。

    .cursor_pointer
    {
     cursor:pointer !important;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-29
      • 1970-01-01
      • 1970-01-01
      • 2020-06-18
      • 1970-01-01
      • 2012-04-27
      • 2019-11-22
      • 1970-01-01
      相关资源
      最近更新 更多