2
  <body>



        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
        </asp:ScriptManager>



            <div id="navarea" style="display: none">
             <asp:UpdatePanel ID="UpdatePanel2" runat="server">
             <ContentTemplate>
            <ul id="navigation" class="treeview" runat="server">

             <li id="parentnode" runat="server">
             Animals
             <asp:Panel ID="Panel1" runat="server">
            <ul id="janwar" runat="server">
            <li id ="test" onclick="getText" runat="server">Goat</li>
            <li id ="test1" runat="server">Cow</li>
       </ul>
     </asp:Panel>
             </li>
             <li id="products" runat="server">
             Products
             <ul runat="server">
             <li runat="server">Apple</li>
             <li runat="server">Samsung</li>
             </ul></li>
             <li id="Accessories" runat="server">
             Drinks
             <ul runat="server">
             <li runat="server">Coca Cola</li>
             <li runat="server">Pepsi</li>
             </ul>
             </li>
            </ul>










     <asp:Label ID="another" runat = "server">sajjad</asp:Label>
        </div>
        <asp:Label ID="Label1" runat = "server">Type here</asp:Label>
        <asp:TextBox ID="testing" runat = "server" Text="ehsan"></asp:TextBox>
        <asp:Panel runat="server">
        <asp:Button ID="swap" runat ="server"  />
        </asp:Panel>
       <asp:HiddenField ID="HiddenField1" runat="server" ClientIDMode="Static" Value="" />


    </ContentTemplate>
    </asp:UpdatePanel>
    </form>
</body>
</html>

这是我的 .aspx 文件代码,我在其中选择用户单击的 li 的 id,当单击按钮时,我将文本框文本设置为该 li 文本。它正在工作,但是在重置回发值后,我想在服务器端保持更改。

这是我的 jquery 脚本

    <script type="text/javascript">



        $(document).ready(function () {

            $("#navigation").treeview({
                persist: "location",
                collapsed: true,
                animated: "medium"
            });
            var ehsan;
            $("#navarea").css("display", "");


             $("#swap").click(function () {

                var temp = $("#testing").val();
                // alert(temp);
                var geting = $("#HiddenField1").attr('Value');

                alert(geting);
                $("li#" + geting + "").html(temp);




              });

            $("#janwar li").click(function () {

                ehsan = this.id;
                $("#HiddenField1").attr('Value', ehsan);
title="change" text="change" value="change" name="change"></button>');




            });
        });




</script>

如何在服务器页面上添加 li 更改?如果有任何示例代码可用?

4

0 回答 0