【发布时间】:2013-12-23 09:29:00
【问题描述】:
dt_msg 是一个数据表,其中我有一些聊天消息,由发送和发送。 我使用这样的字符串生成器将这些消息显示在屏幕上
stringBuilder1.Append("<div style='background-color:ALICEBLUE;float:left; width:100%; word-wrap: break-word;font-size:14px;'><pre><font color='Red'><b><div style='background-color:ALICEBLUE;word-wrap: break-word; margin-right:410px;'>" + dt_msg.Rows[i][2].ToString() + " Says: </b></font></pre></div><div style='background-color:ALICEBLUE;font-size:14px;float: left;width: 410px;margin-left: -410px; word-wrap: break-word;font-size:14px;'><pre><font>" + dt_msg.Rows[i][0].ToString() + "</font></pre></div><div style='background-color:ALICEBLUE; word-wrap: break-word;'><p style='color:#8B8A8A; margin-top:0'>Sent at " + Convert.ToDateTime(dt_msg.Rows[i][1]).ToLongTimeString() + "</p></div><div style='clear:both;'></div>")
现在我将 Ajax 与 webserices 一起使用,现在消息从 webmethod 作为字符串返回,如下所示
User1 says :~Hello to this world and enjoy this week~sent at 05:40:30 AM@#User2 says :~Hello to my world~sent at 05:41:35 AM;
它是在 ajax 代码中接收的
<script type="text/javascript">
function OnSuccess(data) {
if (data.d)
{
div1.innerText = data.d;
}
}
</script>
现在 div1 显示
User1 says :~Hello to this world and enjoy this week~sent at 05:40:30 AM@#User2 says :~Hello to my world~sent at 05:41:35 AM;
但我想显示我在上一页中使用 stringBuilder 显示的消息。如何显示使用 stringBuilder 显示的字符串。这里的字符串@# 是行分隔符
【问题讨论】:
标签: javascript asp.net ajax html asp.net-ajax