2013-04-05 30 views
0

我已經創建了一個Web應用程序,我創建了一個頁面來顯示與Facebook相同的帖子,但我的評論框不在asp.net中工作。評論框相同的Facebook的但在asp.net

[WebMethod] 
public static string LoadImages(int Skip, int Take) { 
    // string image; 
    System.Threading.Thread.Sleep(2000); 
    StringBuilder GetImages = new StringBuilder(); 
    // string Imagespath = HttpContext.Current.Server.MapPath("~/networking/image/"); 
    // string SitePath = HttpContext.Current.Server.MapPath("~/networking"); 
    //var Files = (from file in Directory.GetFiles(Imagespath) select new { image = file.Replace(SitePath, "") }).Skip(Skip).Take(Take); 
    int records = 0; 
    var Files = ProductDataManager.GetRequiredPost(1, 100, ref records).Skip(Skip).Take(Take); 


    foreach(var file in Files) { 
     string postimage = null; 
     if(file.PostImage != "") { 
      postimage = file.PostImage.Replace("\\", "/").Substring(13); 
     } 
     string image = null; 
     if(file.PostImage != "") { 
      image = file.ImageUrl.Replace("\\", "/").Substring(13); 
     } 
     GetImages.AppendFormat(String.Format(@"     
          <div style='clear: both;'> 
           <div style='float: left;'> 
            <img src='{0}' id='userimage1' height='50' width='50' runat='server'/> 
           </div> 
           <div style='float: left; margin-left: 8px; font-family: Arial; font-size: 14px; font-weight: bold; 
            color: Navy;'> 
            <span id='ctl00_ContentPlaceHolder1_gdvgrid_ctl06_username1'>{1}</span> 
           </div> 
           <div style='float: right;'> 

           </div> 
          </div> 
          <div style='margin-left: 70px; clear: both;'> 
           <div style='clear: both; color: Black; font-family: Arial; width: 400px;'> 
            <span id='txtsub1' style='display:inline-block;width:400px;font-family: Arial; font-size: 15px; color: #64635d;'>{2}</span> 
           </div> 
           <div style='clear: both; font-family: Arial;'> 
            <img src='{3}' width='400'/> 
           </div> 
           <div style='color: Black; width: 400px; text-align: justify'> 
            <span style='font-family: Arial; 
             font-size: 12px; color: #64635d; text-align: justify; line-height: 15px;'>{4}</span> 
           </div> 

     <div style='float: left; margin-top: 10px; margin-right: 10px;'> 
       <a onclick='$find(&#39;SendMail3&#39;).show();return false;' id='ctl00_ContentPlaceHolder1_gdvgrid_ctl{6}_btnsendenq' href='href='javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$gdvgrid$ctl{7}$btnsendenq&#39;,&#39;&#39;)' style='font-size: 12px; color: #6d84b4;' tabindex='-1'>Send Enquiry</a> 
     </div> 
     <div style='float: left; margin-top: 10px; margin-right: 10px;'> 
      <a onclick='$find(&#39;Commentdialog&#39;).show();return false;' id='ctl00_ContentPlaceHolder1_gdvgrid_ctl{8}_btnsendenq' href='javascript:__doPostBack(&#39;ctl00$ContentPlaceHolder1$gdvgrid$ctl{9}$lnkcomment&#39;,&#39;&#39;)' style='font-size: 12px; color: #6d84b4;' tabindex='-1'>Comment</a> 
           </div> 
<div style='display: none'> 
      <input type='submit' name='ctl00$ContentPlaceHolder1$gdvgrid$ctl{10}$btncomment' value='Comment' id='ctl00_ContentPlaceHolder1_gdvgrid_ctl{11}_btncomment' style='width:100px;'> 

</div> 

<div style='clear: both; color: #c0c0c0; font-size: 12px; padding-top: 10px; font-weight: bold;'> 
            <span id='ctl00_ContentPlaceHolder1_gdvgrid_ctl06_lbldate'>{5}</span> 
           </div> 
          </div> 

          <div style='border-bottom: 2px solid gray; padding-bottom: 10px;'> 
          </div> 

          ", image, file.CompanyIdentity, file.PostTitle, postimage, file.PostDescription, file.CreateDate, file.Userid, file.Userid, file.ScrapID, file.ScrapID, file.ScrapID, file.ScrapID)); 
    } 
    return GetImages.ToString(); 
} 
+0

1)您需要定義「不工作」。 2)我真的*建議使用另一種方法來構建你的字符串。使用外部模板文件或呈現控件,或使用模板引擎。 – 2013-04-05 08:31:47

回答

0

您可以整合Facebook評論框,而不是實現自己的。

Facebook Comments Box:評論框是一個社交插件,使用戶評論您的網站。功能包括審覈工具和分發。

0

您可以使用asp.net轉發器顯示評論並使用SQL進行存儲評論。 算法 - >獲取名稱和註釋 - >>在sql數據庫表中插入數據 - >>將數據綁定到一個asp.net轉發器。 如何使用asp中繼器:http://www.w3schools.com/aspnet/aspnet_repeater.asp 對於Facebook風格,請使用css。