6 Replies - 3996 Views - Last Post: 21 October 2011 - 06:23 AM

#1 Muaado  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-October 10

how to facebook like comments in asp.net

Posted 19 October 2011 - 11:09 PM

Hi ! I am just starting web development with asp.net c# and i would like to know how i could do programatically create facebook like comments and posts . I have a database table where i have two tables, one for "posts" and one for "comments". in my page_load event i want divs to be created automatically with the respective "class" names. I have already designed the css for this and styled every element. my code behind looks like this for now :


            HtmlGenericControl image = new HtmlGenericControl("div");
            image.Attributes["class"] = "image";
            image.InnerHtml = "<img src=1.jpg width='124px' height='100px' />";
            questimagecontrol.Controls.Add(image);


            HtmlGenericControl userinfo = new HtmlGenericControl("div");
            userinfo.InnerText = "Some One";
            userinfo.Attributes["class"] = "userinfo";
            questcontrol.Controls.Add(userinfo);

            HtmlGenericControl quest = new HtmlGenericControl("div");
            quest.InnerText = "THIS IS A TOTALLY DIFFERENT QUESTION I AM HAVING WHERE ALL DOUBTS ARE BLUNDERS?";
            quest.Attributes["class"] = "question";
            questcontrol.Controls.Add(quest);


            HtmlGenericControl footer = new HtmlGenericControl("div");
            footer.InnerText = "this is footer text";
            footer.Attributes["class"] = "qfooter";
            questcontrol.Controls.Add(footer);



AND here is the html page code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="researching_final_project_components.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link href="style.css" rel="stylesheet" type="text/css" />



    <style type="text/css">
        .style1
        {
            font-family: "Bell MT";
        }
    </style>



</head>
<body>
    <form id="form1" runat="server">
    <div id="main" class="main" runat="server">


         <div class="lquest" id="questimagecontrol" runat="server"> </div>

           <div class="rquest" id="questcontrol" runat="server"></div>
   
    </div>

    </form>
</body>
</html>



i just need to know what is the best approach for doing something like this REPEATEDLY for all the entries in the database for both "postS" and "comments"

This post has been edited by Muaado: 19 October 2011 - 11:11 PM


Is This A Good Question/Topic? 0
  • +

Replies To: how to facebook like comments in asp.net

#2 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: how to facebook like comments in asp.net

Posted 19 October 2011 - 11:21 PM

Each post has an id which is related to the comments table like so.

//posts table
postID    postContent
1         Facebook is great!


//comments table
commentID    postID    comment
2            1         Totally agree!
3            1         Better than MySpace!



After you display every post, you can display the comments that have the same post id. Does this make sense to you? :)
Was This Post Helpful? 0
  • +
  • -

#3 Muaado  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-October 10

Re: how to facebook like comments in asp.net

Posted 19 October 2011 - 11:45 PM

View Postsas1ni69, on 19 October 2011 - 11:21 PM, said:

Each post has an id which is related to the comments table like so.

//posts table
postID    postContent
1         Facebook is great!


//comments table
commentID    postID    comment
2            1         Totally agree!
3            1         Better than MySpace!



After you display every post, you can display the comments that have the same post id. Does this make sense to you? :)


Thanks but this is not what i ask for ! I am having problems not with the database , but how to load every post and comment in the database as a div ! can u help me on that ? thanks
Was This Post Helpful? 0
  • +
  • -

#4 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: how to facebook like comments in asp.net

Posted 19 October 2011 - 11:53 PM

Sorry if I misunderstood what you were trying to say. Alright I'm not experienced in C# but the idea is generally the same so I'll write up the semi-pseudo code and maybe you can translate it to C#.

1. Load the posts from the database.
2. Load the comments. (You can use a join statement)
3. Loop the posts and within that loop the comments.

Something like this:

for each post(){
    <div class="post">display post</div>
       for each comment relating to post(){
           <div class="comment">display comment</div>
       }
}



Does this make more sense? :)
Was This Post Helpful? 1
  • +
  • -

#5 Muaado  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-October 10

Re: how to facebook like comments in asp.net

Posted 20 October 2011 - 07:00 AM

View Postsas1ni69, on 19 October 2011 - 11:53 PM, said:

Sorry if I misunderstood what you were trying to say. Alright I'm not experienced in C# but the idea is generally the same so I'll write up the semi-pseudo code and maybe you can translate it to C#.

1. Load the posts from the database.
2. Load the comments. (You can use a join statement)
3. Loop the posts and within that loop the comments.

Something like this:

for each post(){
    <div class="post">display post</div>
       for each comment relating to post(){
           <div class="comment">display comment</div>
       }
}



Does this make more sense? :)


nah ! still not what i was asking !
Was This Post Helpful? 0
  • +
  • -

#6 sas1ni69  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 85
  • View blog
  • Posts: 431
  • Joined: 04-December 08

Re: how to facebook like comments in asp.net

Posted 20 October 2011 - 07:47 AM

Aww :( maybe you can explain a little bit more?
Was This Post Helpful? 0
  • +
  • -

#7 Muaado  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 26-October 10

Re: how to facebook like comments in asp.net

Posted 21 October 2011 - 06:23 AM

View Postsas1ni69, on 20 October 2011 - 07:47 AM, said:

Aww :( maybe you can explain a little bit more?


Yes, I want to know how i can create multiple divs , layered one inside each other , programatically ... thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1