一、ScriptManager
ScriptManager.RegisterClientScriptBlock(this, GetType(), "aaa", "alert('下单成功/Order Success');", true);
ScriptManager.RegisterClientScriptBlock(this, GetType(), "aaa", "alert('下单失败/Order failure," + ex + "');", true);
二、InnerHtml
首先在HTML页面添加如下代码
<table id="TabMsg" runat="server">
<tr>
<td>
</td>
</tr>
</table>
后台
TabMsg.Rows[0].Cells[0].InnerHtml = "";
TabMsg.Rows[0].Cells[0].InnerHtml = "<script language='javascript'>alert('下单成功,我们会尽快帮您处理/Order Success')</script>";
TabMsg.Rows[0].Cells[0].InnerHtml = "<script language='javascript'>alert('下单失败/Order failure" + ex + "')</script>";
这个方法要注意提示语句中的单引号’,如果想加一个string字段,要“加入,在‘之前