Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 .....
------------------------------------------------------------------------------




ASP.NET
<%@ 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 .....
Posted
Updated 28-Oct-11 6:49am
v2
Comments
[no name] 28-Oct-11 15:18pm    
Posting the entire page is very distracting, especially since it is not formatted very well. Try just posting the relevant part, not everything.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900