如何在服务器端添加使用jquery在客户端完成的更改

时间:2012-07-05 06:45:36

标签: jquery server-side

  <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更改?如果有任何样本代码可用吗?

0 个答案:

没有答案