@第一种方法(错误的方法):

1,前台添加一个Literal控件

<asp:Literal ID="alertMsg" runat="server"></asp:Literal>

2,后台,向控件赋值,值为html格式文件。然后前台就会展示出来。

alertMsg.Text = @"<div style='width:758px;height:50px;padding-top:20px;padding-left:178px;display:block;'>
<div style='float:left;width:30px;'><img src='http://www.chinawutong.com/pic/Error_line.gif' alt='X'></div>
<div style='float:left;width:370px;color:#333333;font-size:18px;font-weight:bold'>暂时没有搜到符合您查询条件的搬家公司。 </div></div>
<div style='width:250px;color:#333333;font-size:18px;font-weight:bold;margin:0 auto;'>请您更改筛选条件重新查询。</div>
<div style='width:550px;color:#333333;font-size:18px;font-weight:bold;margin:0 auto;'>或您可以点此<a target='_blank' href='http://www.chinawutong.com/reg.aspx'><span style='color:red;'>注册会员<span></a>发布搬家信息让搬家公司主动找上您。</div>";

3,会出现一个问题,后台cs文件像前台输出html标签的话,会保存在viewstate中,只要viewstate中有这段html代码,那么页面中就会显示这段html代码,不管你怎么请求,请求的结果是什么,页面中都会显示这段html代码。这样不行。所以用下边方法。

@第二种方法(正确方法):

1,用样式控制!!!

<div class='yqtsy' style="display:<%=tip_display%>;">
                    <div style='width: 550px; height: 30px; padding-top: 20px; padding-left: 158px; display: block;'>
                        <p style='float: left; width: 30px;'>
                            <img src='http://www.chinawutong.com/pic/Error_banjia.gif' alt='X'></p>
                        <p style='float: left; width: 380px; color: #333333; font-size: 20px; font-weight: bold'>暂时没有搜到符合您查询条件的搬家公司</p>
                    </div>
                    <div class='erh'>请您更改筛选条件重新查询</div>
                    <div class='sanh'>或您可以点此<a target='_blank' href='http://www.chinawutong.com/reg.aspx' style='color: #0033f8; text-decoration: underline;'>注册会员</a>发布搬家信息让搬家公司主动找上您。</div>
                </div>
                <div class="cl"></div>

posted on 2014-03-31 17:01  学到老死  阅读(243)  评论(0编辑  收藏  举报