locked
CLient Callback RRS feed

  • Question

  • User719395276 posted

     Hi i have done this code using Ajax,Can someone do this fr me using CLient Callback,

    ASPX,

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FaceBookHome.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
        <script type="text/javascript">
        function DeleteComment(commentID)
        {
        document.getElementById('hdnMsg').value = commentID;
        var id='table'+commentID;
       
        document.getElementById(id).style.display="none";
        document.getElementById('hdnComntID').click();
        }
       

        </script>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server" />
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                   
                       
                  
            <br />
           
            <div><%for (int i = 0; i < objComment.Tables[0].Rows.Count; i++)%>
                        <%{ %>
                  
                <table style="width: 920px; height: 64px; display:block;" id="table<%=objComment.Tables[0].Rows[i]["intCommentID"].ToString() %>">
                    <tr>
                        <td style="width: 100px">
                            <img src="Images/<%=objComment.Tables[0].Rows[i]["Image"].ToString() %>" style="width: 80px" />
                            </td>
                        <td style="width: 693px">
                            <table style="width: 688px; height: 80px">
                                <tr>
                                    <td>
                                        <%--<asp:Label ID="lblUserName" runat="server" Font-Bold="True" Font-Names="Copperplate Gothic Bold" Font-Size="Large" ForeColor="Blue"></asp:Label></td>--%>
                                        <span style="color:Blue; font-size:x-large; font-family:Copperplate Gothic Bold"><%=objComment.Tables[0].Rows[i]["txtUserName"].ToString() %></span></td>
                                </tr>
                                <tr>
                                    <td>
                                        <span><%=objComment.Tables[0].Rows[i]["txtComment"].ToString() %></span></td>
                                </tr>
                                <tr>
                                    <td>
                                        <span style="color:Gray;"><%=objComment.Tables[0].Rows[i]["datetime"].ToString() %></span></td>
                                </tr>
                            </table>
                        </td>
                        <td>
                            <%--<asp:ImageButton ID="ImageButton1" ImageUrl="~/Images/Cancel.jpg" runat="server" Height="32px" OnClick="ImageButton1_Click" />--%>
                            <img src="Images/Cancel.jpg" onclick="DeleteComment('<%=objComment.Tables[0].Rows[i]["intCommentID"].ToString() %>')" style="width: 32px; height: 40px" id="IMG1" alt="Images/club.jpg" />
                            </td>
                    </tr>
                </table>
              
                <%} %>
                <%--<button id="hdnComntID" style="display:none;  width: 48px;"  runat="server" onserverclick="btnDeleteComment"></button>--%>
                 <input id="hdnComntID" type="button" value="button" style="display:none;" runat="server" onserverclick="BtnDeleteComment"  />
                <input id="hdnMsg" type="hidden" runat="server" />
                <table style="width: 912px">
                    <tr>
                        <td style="width: 164px">
                        </td>
                        <td style="width: 571px">
                        </td>
                        <td>
                            <asp:LinkButton ID="lnlViewMore" runat="server" OnClick="lnlViewMore_Click"></asp:LinkButton>
                            <asp:LinkButton ID="lnkHide" runat="server" OnClick="lnkHide_Click"></asp:LinkButton></td>
                    </tr>
                </table>
               
               
            </div>
                </ContentTemplate>
            </asp:UpdatePanel>
            
        </form>
      
    </body>
    </html>

     

    here is the code behind,

    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class _Default : System.Web.UI.Page
    {
        protected DataSet objComment;
        protected DataSet ds;
        protected int CommentperPage = 3;
        protected int PageIndex=0, NoOfRows=3, TotalComments=0,increment=1,ObjCount;

        ClsComments clsComnt = new ClsComments();
        protected void Page_Load(object sender, EventArgs e)
        {
            objComment = new DataSet();
            if (!Page.IsPostBack)
            {
                objComment = clsComnt.GetComments(PageIndex, NoOfRows, ref TotalComments);
                ViewState["NoOfDisplayed"] = objComment.Tables[0].Rows.Count;
                ViewState["Commnt"] = objComment;
            }
            if (ViewState["Commnt"] != null)
            {
                objComment = (DataSet)ViewState["Commnt"];
            }

                   
            lnlViewMore.Enabled = true;
            lnlViewMore.Text = "View More";
        }
       
        protected void BtnDeleteComment(object sender, EventArgs e)
        {
           
                int CommentID = Convert.ToInt32(hdnMsg.Value.Trim());
                clsComnt.deleteComment(CommentID);
        }

        protected void lnlViewMore_Click(object sender, EventArgs e)
        {
            PageIndex = (int)ViewState["NoOfDisplayed"];
          
            objComment = (DataSet)ViewState["Commnt"];
            DataSet ds = new DataSet();
            ds = clsComnt.GetComments(PageIndex, NoOfRows, ref TotalComments);
            ViewState["DataOnViewMore"] = ds;
            if (ds != null)
            {
                objComment.Merge(ds);
                ViewState["Commnt"] = objComment;
                ViewState["NoOfDisplayed"] = objComment.Tables[0].Rows.Count;
            }
            if (objComment.Tables[0].Rows.Count == TotalComments)
            {
                lnlViewMore.Enabled = false;
            }
        }
        protected void lnkHide_Click(object sender, EventArgs e)
        {
           
        }
    }

    Tuesday, March 24, 2009 11:26 AM

Answers

All replies