int TopicID = ConvertHelper.ToType<int>(context.Request["TopicID"], 0);
if (TopicID > 0)
{
List<VReplay> lstReplay = ModelShowManagerDataAccess.GetReplayByTopicID(TopicID);
StringBuilder Terms = new StringBuilder();
string resault = "{\"resault\":\"ok\",\"Replays\":[";
foreach (VReplay item in lstReplay)
{
Terms.Append("{\"ReplayID\":\"" + item.ReplayID + "\"");
Terms.Append(",\"ReplayContent\":\"" + Server.HtmlEncode(item.ReplayContent).ToString() + "\"");
Terms.Append(",\"ReplaySmallPic\":\"" + item.ReplaySmallPic + "\"");
Terms.Append(",\"ReplayBigPic\":\"" + item.ReplayBigPic + "\"");
Terms.Append(",\"ReplayAcceptDateValue\":\"" + item.ReplayAcceptDateValue + "\"");
Terms.Append(",\"ReplayAttachment\":\"" + item.ReplayAttachment + "\"");
Terms.Append(" },");
}
resault += Terms.ToString().TrimEnd(',') + "]}";
context.Response.Write(resault);
}
else
{
context.Response.Write("{\"resault\":\"error\"}");
}
<%前台拼%>
function SpellTopicHtml(JsonData) {
var Html = '';
if (JsonData.length == 0) {
Html += '没有待发布的问题!';
}
else {
for (var i = 0; i < JsonData.length; i++) {
Html += '<div class="question" style="width: 645px; text-align: left; padding-bottom: 10px;">';
Html += ' <div class="topicTop">';
Html += ' </div>';
Html += ' <div class="topicCont">';
Html += ' <p style="margin: 0; padding: 0; text-align: right;">';
Html += ' <span class="Timer">' + JsonData[i].CreateDateValue + '</span>';
Html += ' </p>';
Html += ' <p style="margin: 0; padding: 0; overflow: hidden; text-overflow: ellipsis;">' + JsonData[i].TopicContent + '</p>';
if (JsonData[i].TopicAttachment != '') {
Html += ' <div id="' + 'divSmall' + JsonData[i].TopicID + '" class="smallPhoto" οnclick="ShowBigPic(' + JsonData[i].TopicID + ');" >';
Html += ' <img width="100" src="' + JsonData[i].TopicSmallPic + '" alt="">';
Html += ' </div>'
Html += ' <div id="' + 'divBig' + JsonData[i].TopicID + '" class="bigPhoto" style="display: none;" οnclick="ShowSmallPic(' + JsonData[i].TopicID + ');">';
Html += ' <img width="300" src="' + JsonData[i].TopicBigPic + '" alt="">';
Html += ' </div>';
}
Html += ' <div class="textLinks">';
Html += ' <span ><a id="<%# "aOpen"+Eval("TopicID")%>" class="textLinks6" style="color: #1861d1; ';
Html += ' font-weight: normal;" href="javascript:" οnclick="SetTop(' + JsonData[i].TopicID + ')">置顶</a></span>';
Html += ' <span ><a id="<%# "aOpen"+Eval("TopicID")%>" class="textLinks3" style="color: #1861d1; ';
Html += ' font-weight: normal;" href="javascript:" οnclick="RemoveTopic(' + JsonData[i].TopicID + ')">移除</a></span>';
Html += ' </div>';
Html += ' </div>';
Html += ' <div class="topicBottom">';
Html += ' </div>';
Html += ' </div>';
}
}
return Html;
}