0

我的标题部分是

<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>SimpleAdmin</title>
<script type="text/javascript" src="js/jquery-1.7.2.min.js"></script>   
<script type="text/javascript">
    $(function () {
        $(".box .h_title").not(this).next("ul").hide("normal");
        $(".box .h_title").not(this).next("#home").show("normal");
        $(".box").children(".h_title").click(function () {$(this).next("ul").slideToggle(); });
    });
</script>   
</head>

还有我的身体部分

<body>
<form id="form" runat="server">  

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>    

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>        
<asp:DataList ID="dtlheader" runat="server" Width="189px">
        <ItemTemplate>
         <table cellpadding="0" cellspacing="0" width="100%" onmouseover="this.style.background='#683372'" onmouseout="this.style.background='#3e3d3b'"  style="background-color: #3e3d3b;">
         <tr>
         <td>
            <div class="box">
              <div class="h_title" style="color: #FFFFFF"><%# Eval("header") %></div>
                <ul>
                    <asp:DataList ID="dtlsubtitle" runat="server">
                        <ItemTemplate>
                            <table cellpadding="0" cellspacing="0" width="100%" onmouseover="this.style.background='#ececec'"
                                                    onmouseout="this.style.background='#ececec'"  style="background-color: #ececec;"><tr><td>
                               <asp:LinkButton ID="lnk" runat="server" onclick="lnk_Click"><%# Eval("subtitle") %></asp:LinkButton>
                                </td></tr></table>
                        </ItemTemplate>
                    </asp:DataList>
                </ul>
            </div>
            </td>
            </tr>
            </table>
        </ItemTemplate>
    </asp:DataList>  
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>

这是switchmenu的脚本 在第 1 页加载时它运行良好,但是在点击里面的链接按钮时,比在脚本不再工作之后。

4

1 回答 1

0

如果我理解你的问题,这应该可以解决它:

Javascript

$(function () {        
    $(".box .h_title").not(this).next("ul").hide("normal");
    $(".box .h_title").not(this).next("#home").show("normal");
});

function lbClicked(obj) {
    $(obj).next("ul").slideToggle(); 
}

ASP.NET

<asp:LinkButton ID="lnk" runat="server" onclick="lnk_Click" onclientclick="lbClicked(this)"><%# Eval("subtitle") %></asp:LinkButton>

C#

protected void Page_Load(object sender, EventArgs e)
{
    // You don't need the line below, which is wrong anyway
    //ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "function();", true);

}
  protected void lnk_Click(object sender, EventArgs e)
{
    // You don't need the line below, which is wrong anyway 
    //ScriptManager.RegisterStartupScript(this, this.GetType(), "javascript", "function();", true);
}
于 2013-08-09T12:56:49.890 回答