jquery刷新div按钮单击asp .net

时间:2014-05-22 07:01:14

标签: javascript jquery asp.net

我试图通过按钮点击刷新div,但一定是错误的。我也在使用asp.net和jquery。如果你们可以帮助我那将是非常棒的

 $('#addmebaby').click(function () {
     $.ajax({
         url: "MenuControl.aspx",

         type: "GET",
         dataType: "html",
         success: function (data) {
             var result = $('<div />').append(data).find('#MenuDiv').html();
             $('#MenuDiv').html(result);
         },
         error: function (xhr, status) {
             alert("Sorry, there was a problem!");
         },
         complete: function (xhr, status) {
             //$('#showresults').slideDown('slow')
         }
     });
 });

这里的整个代码

 <script>

     function refreshDiv() {

         $('#addmebaby').click(function () {
             $.ajax({
                 url: "MenuControl.aspx",

                 type: "GET",
                 dataType: "html",
                 success: function (data) {
                     var result = $('<div />').append(data).find('#MenuDiv').html();
                     $('#MenuDiv').html(result);
                 },
                 error: function (xhr, status) {
                     alert("Sorry, there was a problem!");
                 },
                 complete: function (xhr, status) {
                     //$('#showresults').slideDown('slow')
                 }
             });
         });
     }

  $(function () {

     $("#dialog-form").dialog({
          autoOpen: false,
          height: 300,
          width: 350,
          modal: true,
        appendTo: AddForm,
      });



      $("#create-user")
        .button()
        .click(function () {
            $("#dialog-form").dialog("open");

        });

      $("#dialog-form-edit").dialog({
          autoOpen: false,
          height: 300,
          width: 350,
          modal: true,
          appendTo: AddForm,
      });




  });



 </script>

列出,编辑,删除表格

<div class="page-content-wrapper">
    <div class="page-content">





        <div class="row">
            <div class="col-md-12">
                <!-- BEGIN PAGE TITLE & BREADCRUMB-->
                <h3 class="page-title">
                MFT Haber Scripti V1  <small>Admin Paneli</small>
                </h3>
                <ul class="page-breadcrumb breadcrumb">
                    <li>
                        <i class="fa fa-home"></i>
                        <a href="index.html">Home</a>
                        <i class="fa fa-angle-right"></i>
                    </li>
                    <li>
                        <a href="#">Dashboard</a>
                    </li>
                    <li class="pull-right">

                    </li>
                    <li>
                    </li>
                </ul>
                <!-- END PAGE TITLE & BREADCRUMB-->
            </div>
        </div>
        <!-- END PAGE HEADER-->

        <div class="clearfix">

 <!-- BEGIN EXAMPLE TABLE PORTLET-->
                <div class="portlet box blue" >
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="fa fa-edit"></i>Düzenleme Tablosu

                        </div>

                    </div>
                    <div class="portlet-body">
                        <div class="table-toolbar">
                            <div class="btn-group">


                            <input type="button" value="Yeni Ekle +" Id="create-user" class="btn green"   />    

                            </div>
                            <ul style="float:right">
                            <asp:Button ID="Button7" runat="server" Text="Seçilenleri Sil" BackColor="Red" CssClass="btn green" OnClick="Button7_Click" />
                            </ul>
                        </div>
                        <div id="MenuDiv">
                        <table class="table table-striped table-hover table-bordered" id="table" >
                        <thead>
                        <tr>
                            <th>

                              Seç  

                            </th>
                            <th>
                                Baslik
                            </th>


                            <th>
                                Edit
                            </th>
                            <th>
                                Delete
                            </th>
                        </tr>
                        </thead>
                        <tbody>
                        <asp:Repeater runat="server" ID="repMasterMenu"><ItemTemplate>
                        <tr>
                            <td><asp:CheckBox ID="CheckBox1" runat="server"  /></td>
                            <td>
                                <%#Eval("MenuName") %>
                            </td>


                            <td>


                               <asp:ImageButton ID="Duzen" runat="server" OnClientClick="$('#dialog-form-edit').dialog('open');"   ImageUrl="~/admin/img/duzenle_16x16.gif"  CommandArgument=<%#Eval("Id") %>   onclick="Duzenle" Width="10px"  />

                                <!--<a href="#" class="btn default btn-xs purple"><i class="fa fa-edit"></i> Edit</a>-->
                            </td>
                            <td>
                                <asp:ImageButton ID="Sil" ImageUrl="~/admin/img/sil_16x16.gif" runat="server" CommandArgument=<%#Eval("Id") %> onclick="sil" width="10px"/>

                            <!--    <a href="#" class="btn default btn-xs black"><i class="fa fa-trash-o"></i> Delete</a>-->
                            </td>
                        </tr>

                                      </ItemTemplate></asp:Repeater>
                        </tbody>
                        </table>
                            </div>
                    </div>
                </div>


                <!-- END EXAMPLE TABLE PORTLET-->

                </div>

弹出式广告

  

&LT; div id =&#34; dialog-form&#34; &GT;    &LT;字段集&GT;    &LT;标签&gt;名称     &LT; asp:TextBox ID =&#34; name&#34; RUNAT =&#34;服务器&#34; &GT;   &LT; asp:Button runat =&#34; server&#34; ID =&#34; addmebaby&#34;文字=&#34;加我宝贝&#34;的OnClick =&#34; addmebaby_Click&#34; /&GT;    &LT; /字段集&GT;

     

&LT; / DIV&GT;

           <div id="dialog-form-edit" >
     名称                         

</div>



<!-- END CONTENT -->

      

1 个答案:

答案 0 :(得分:0)

function refreshDiv(){

       $.ajax({ url: "MenuControl.aspx",

             type: "GET",
             dataType: "html",
             success: function (data) {
                 var result = $('<div />').append(data).find('#MenuDiv').html();
                 $('#MenuDiv').html(result);
             },
             error: function (xhr, status) {
                 alert("Sorry, there was a problem!");
             },
             complete: function (xhr, status) {
                 //$('#showresults').slideDown('slow')
             }
         });

}

将此功能附加到元素onclick =&#39; refreshDiv()&#39;