为什么Ajax在页面的某些部分工作而在某些部分的工作 [英] why ajax work in some part of the page and dosent in some parts

查看:60
本文介绍了为什么Ajax在页面的某些部分工作而在某些部分的工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我单击Enter并使用btnaddcomment按钮对abb进行注释时,页面上将重新加载页面和ajax单词,但是当我单击add_post_btn按钮时,ajax上一页的工作和页面释放.....
-------------------------------------------------- ----------------------------




when i click enter to abb comment with the btnaddcomment button the page dosent reload and the ajax word but when i click the add_post_btn button ajax dosent work and the page relod .....
------------------------------------------------------------------------------




<%@ Page Language="C#" MasterPageFile="~/teacher/teacherMasterPage.master" AutoEventWireup="true"

    CodeFile="allposts.aspx.cs" Inherits="teacher_allposts" Title="posts" %>

<%--<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit.HTMLEditor"
    TagPrefix="cc1" %>--%>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
<style type="text/css" >

#centertd
{ text-align:left;

}
</style>
  

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    
        
           
               
         <asp:UpdatePanel ID="postsajax" runat="server" >
         
                
                <contenttemplate>
                
                
               <br /><br /><br />
                
               
        
            <asp:TextBox ID="add_post_txt" runat="server" Height="59px" Width="416px" 

                        OnTextChanged="add_post_txt_TextChanged" BorderColor="Maroon" 

                        TextMode="MultiLine">
            <br />
            <asp:FileUpload ID="FileUploadPost" runat="server" Visible="false" />
 
             <br />
             
             
            <asp:Button ID="add_post_btn" runat="server" Text="Post" OnClick="btnInsertPost"

                Width="83px" ForeColor="Black" BackColor="#CCCCCC" />
            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click" ForeColor="Black">Upload 
                    what u want
                    
       
           
          
            
       
       
            <br />
        
                    <asp:Label ID="Label_upload_file" runat="server">
                    <br />
                   
         
            
                <%-----------------parent datalist for posts---------------------------------------%>
                
                <asp:DataList ID="posts_datalist" runat="server" DataKeyField="id" OnItemDataBound="posts_datalist_ItemDataBound"

                    OnSelectedIndexChanged="posts_datalist_SelectedIndexChanged" OnItemCommand="posts_datalist_ItemCommand"

                    OnDeleteCommand="posts_datalist_DeleteCommand" Width="400" 

                        style="margin-right: 0px">
                    <itemtemplate>
                   
                        <table border="0" width="400px">
                        
                            <tr>
                                
                                 
                                
                                    <td width="74px">   
                                           <asp:Image ID="post_user_image" runat="server" ImageUrl='<%#"../images/thump"+DataBinder.Eval(Container.DataItem,"picture") %>' Width="74px" Height="61px"/>
                                          
                                   </td> 
                                   <td id="centertd" align="left">  
                                          <asp:Label ID="Label1" Font-Italic=true ForeColor="Maroon" runat="server" Text=""><%# DataBinder.Eval(Container.DataItem, "user_name")%>
                                   </td>
                                   <td align="right">
                                  
                                        <asp:Button ID="dtndelete" runat="server" Text="X" Height="16px" Width="16px" CommandName="Delete" Visible="false" 

                                        

                                        

                                        

                                        

                                            CommandArgument='<%#Eval("id") %>'  />
                                   </td>
                             
                                
                                
                          </tr>
                          <tr width="500">
                          <td colspan="1"></td>
                                <td colspan="2" width="500">
                              
                                
                                  <div style=" height:100%; text-align:left; margin:10px 0px; width:200">
                                  
                                  <a id="LinkButtontext" href='<%#"../files/post/"+Eval("post_upload") %>' visible="false"  runat="server">
                                  <img src="../images/text.png" width="50px" height="50px" hspace="10" vspace="3"   />                                 
                                                                  
                                  <a id="LinkButtonword" href='<%#"../files/post/"+Eval("post_upload") %>'

                                  visible="false"  runat="server">
                                  <img src="../images/word.png" width="50px" height="50px" hspace="10" vspace="3"  />
                                                                                                  
                                  <a id="LinkButtonexcel" href='<%#"../files/post/"+Eval("post_upload") %>'

                                  visible="false"  runat="server">
                                 <img src="../images/excel.png" width="50px" height="50px" hspace="10" vspace="3"  />
                                 
                                   <a id="photo" href='<%#"../images/"+Eval("post_upload") %>'

                                  visible="false"  runat="server">
                                 <img src='<%#"../images/thump"+Eval("post_upload") %>' hspace="10" vspace="3" align="baseline"/>
                                 
                                                                    
                                  
                              <span>    <asp:Label ID="post_content" runat="server" Width="200" style="word-wrap:break-word"    Text="" ForeColor="Black" ><%# DataBinder.Eval(Container.DataItem, "post_content")%></span>
                                  <br />
                                                                                       
                                     <asp:Label ID="Label2"  runat="server" ForeColor="Black"  Font-Size="X-Small" Text='<%#Eval("date") %>'>
                                  
                                  </div>
                                    
                                </td>
                                
                            </tr>
                         
                            <tr id="trcommet"  runat="server" visible="false" height="5px">
                            <td colspan="1"></td>
                                <td id="td_comment" colspan="2" bgcolor="silver" visible="false">
                                   <%-- -------------- datalist of comments----------------------------------------%>
                                    <asp:DataList ID="comments_datalist" runat="server" DataKeyField="id">
                                        <itemtemplate>
                                           
                                       <table bgcolor="silver" border="0">
                                             
                                                 <tr width="100px" bgcolor="silver">
                                                    <td valign="top">
                                                        <asp:Image ID="comments_user_image" runat="server" ImageUrl='<%#"../images/thump"+DataBinder.Eval(Container.DataItem,"picture") %>' Width="40px" Height="30px"/>
                                                    </td>
                                                    <td align="left">
                                                    <asp:Label ID="labusernamecomment" Font-Italic=true  ForeColor="Maroon" runat="server" Text=""><%# DataBinder.Eval(Container.DataItem, "user_name")%>
                                                    <asp:Label ID="comment_content" runat="server" Width="300" style="word-wrap:break-word" Text="" ForeColor="Black"><%#DataBinder.Eval(Container.DataItem, "comment_content")%>
                                                    </td>
                                                    </tr>
                                                
                                            </table>
                                        </itemtemplate>
                                    
                <%-- //----------------------------------------end of comment datalist--------------------------------------------//--%>
        
                                </td>
                              
                                
                            
                            <tr>
                            <td colspan="1"></td>
                                <td colspan="2">
                                
                                    <asp:Panel ID="Panel1" runat="server" DefaultButton="btnaddcomment">                                                     
                                    <asp:Button ID="btnaddcomment" runat="server"  Text="add" CommandName="btn_comment_add"

                                        CommandArgument='<%#Eval("id") %>' style="display:none" />
                                    <asp:TextBox ID="txtComment"  runat="server"  Width="400px" Height="20px" Visible="false" >
                                    
                                      
                                    
                                    
                                    
                                    <asp:LinkButton ID="comment_link" ForeColor="Maroon" Font-Size="X-Small" Font-Bold="true" runat="server" CommandName="linkcomment" CommandArgument='<%#Eval("id") %>'>Comment
                              
                                 
                                </td>
                            
                               
                                    
                                
                            </tr>
                        </table>
                        <hr color="black" />
                         
                    </itemtemplate>
                
                
                <asp:LinkButton ID="prv" runat="server" onclick="prv_Click"><<

                           

                <asp:LinkButton ID="next" runat="server" onclick="next_Click">>>
                
                    <asp:Label ID="lblError" runat="server"  Visible="false">   
                
        </contenttemplate>
        <triggers>
        <asp:PostBackTrigger ControlID="add_post_btn" />
        
        </triggers>


-----------------------------------------------------------------------------------when i click enter to abb comment with the btnaddcomment button the page dosent reload and the ajax word but when i click the add_post_btn button ajax dosent work and the page relod .....


-----------------------------------------------------------------------------------when i click enter to abb comment with the btnaddcomment button the page dosent reload and the ajax word but when i click the add_post_btn button ajax dosent work and the page relod .....

推荐答案

The only way you''re going to get through this is to write some code to catch your Ajax errors, or to use the Developer Tools in IE or Chrome (or Firebug in FireFox) to see what''s happening.

If you get an Ajax error, it''s not at all unlikely to expect that your scripts will stop working. You need to first figure out what''s going wrong, before you can fully figure out what''s going wrong ;)

Developer tools are accessible by pressing F12. You can get Firebug here[^].

干杯.
The only way you''re going to get through this is to write some code to catch your Ajax errors, or to use the Developer Tools in IE or Chrome (or Firebug in FireFox) to see what''s happening.

If you get an Ajax error, it''s not at all unlikely to expect that your scripts will stop working. You need to first figure out what''s going wrong, before you can fully figure out what''s going wrong ;)

Developer tools are accessible by pressing F12. You can get Firebug here[^].

Cheers.


这篇关于为什么Ajax在页面的某些部分工作而在某些部分的工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆