none
怎么动态修改aspx页面上的li元素? RRS feed

  • 问题

  • <asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder2">
    <ul id="UL1" runat="server">                                                                      
                <li class="selected"><a href="index.aspx">首页</a></li><li><a href="readbook.aspx">浏览图书</a></li><li><a href="searchbook.aspx">查找图书</a></li><li><a href="member.aspx">会员中心</a></li><li><a href="crat.aspx">购物车</a></li><li><a href="register.aspx" >注册</a></li><li><a href="login.aspx?url2=index.aspx" id="A1" >登入</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    <asp:Label ID="Label1" runat="server" Font-Size="10pt" ForeColor="#FFFF66"></asp:Label></li><li></li></ul>
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
        &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
    </asp:Content>

    我希望通过程序控制 Content中某个li里面超链接的地址和对应的文字,怎么做到?例如,我想在某种情况下,将上面的
    <li><a href="login.aspx?url2=index.aspx" id="A1" >登入</a> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                    <asp:Label ID="Label1" runat="server" Font-Size="10pt" ForeColor="#FFFF66"></asp:Label></li>
    中的login.aspx修改为logout.aspx,同时将“登入”修改为“登出”。
    求助各位高手指点,谢谢。
    2010年1月27日 11:17

答案

  • document.getElementBuId("A1").innerHTML="登出"
    document.getElementBuId("A1").href="logout.aspx"

    如果在服务器端执行,你加上 runat="server"即可,。或者采用HyperLink服务器控件
    【孟子E章】
    2010年1月27日 11:55
    版主