iframe 调用asp页面实现动态数据展示

来源:互联网 发布:java语言的特点 编辑:程序博客网 时间:2024/06/09 21:46
1、用户自定义控件:
<% @ Control Language="C#" AutoEventWireup="true" CodeBehind="right.ascx.cs" Inherits="ProjectName.right" %>
<div class="rightcon">
    <h3>
        今日指标 <% --<span class="more"> 更多>></span>--%> </h3>
    <iframe src="cjrlRight.asp" id ="iframeColor"  allowTransparency ="true"  frameborder ="no" width ="262" style ="background-color: #fff" min-height="300" ></iframe>
</div>


2.ASP页面 cjrlRight.asp

<!--#include file="conn.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content ="text/html; charset=utf-8" />
    <title></title >
    <link href="css/body.css" rel ="stylesheet" type ="text/css" />
</head>
<body style="background-color :#fff" >
    <div class="Froexblcok">
         <table width="100%" border="0" cellspacing="0" cellpadding="0" id="tableImportant">
                <tr>
                    <th>
                        时间
                    </th>
                    <th>
                        国家
                    </th>
                    <th>
                        指标名称
                    </th>
                </tr>
                <%
                    set rs=server.createobject("adodb.recordset" )
                    sql= "select * from tableInfo"
                                rs.open sql,conn12,1,1  
                                if rs.eof and rs.bof then response.write "<span style='color: Black; font-size: 12px;'>暂无数据 ...</span>    <script type='text/javascript'>document.getElementById('tableImportant').style.display = 'none'; </script>"
                                do while not rs.eof
                %>
                <tr>
                    <td>
                        <%=rs( "TIME") %>
                    </td>
                    <td>
                        <%=rs( "country") %>
                    </td>
                    <td class="tdclass">
                        <%=rs( "ITEM") %><%=rs( "TableData") %>
                    </td>
                </tr>
                <%
                    rs.movenext
                                loop
                                rs.close
                                set rs=nothing
                                conn12.close
                                set conn12=nothing  
                %>
            </table>
    </div>
</body>
</html>
3.ASP.Net页面调用
<% @ Register Src="~/right.ascx" TagName="Right" TagPrefix="uc2" %>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
< title>  </title >
< link href ="css/body.css" rel ="stylesheet" type ="text/css" />
< script type ="text/javascript" src ="js/jquery.min.js"></ script >
</ head>
< body>
    < form id ="form1" runat ="server">
          < uc2: Right ID ="Right" runat ="server" />
    </ form>
</ body>
</ html>




原创粉丝点击