框架页面尽可以这么用(后置代码中控制框架)

    xiaoxiao2022-05-21  190

    下面是框架页:

    <%@ Page CodeBehind="Frameset.aspx.cs" Language="c#" AutoEventWireup="false" Inherits="IbatisTest.Web.Frameset" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"> <HTML> <HEAD> <TITLE>内容框架集</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=gb2312"> <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1"> <meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"> </HEAD> <frameset cols="150,*" id="detail" runat="server"> <frame name="contents" id="contents" runat=server src=""></frame> <frame name="main" id="main" src="" runat="server"></frame> <noframes> <p id="p1"> 此 HTML 框架集显示多个 Web 页。若要查看此框架集,请使用支持 HTML 4.0 及更高版本的 Web 浏览器。 </p> </noframes> </frameset> </HTML> 后置代码如下: 1using System.Data; 2using System.Drawing; 3using System.Web; 4using System.Web.SessionState; 5using System.Web.UI; 6using System.Web.UI.WebControls; 7using System.Web.UI.HtmlControls; 8 9namespace IbatisTest.Web 10{ 11 /// <summary> 12 /// Frameset 的摘要说明。 13 /// </summary> 14 public class Frameset : System.Web.UI.Page 15 { 16 protected System.Web.UI.HtmlControls.HtmlGenericControl detail; 17 protected System.Web.UI.HtmlControls.HtmlGenericControl contents; 18 protected System.Web.UI.HtmlControls.HtmlGenericControl main; 19 20 private void Page_Load(object sender, System.EventArgs e) 21 { 22 detail.Attributes.Add("src","default.aspx"); 23 detail.Attributes.Add("framespacing", "0") ; 24 detail.Attributes.Add("frameborder", "0") ; 25 detail.Attributes.Add("marginwidth", "0") ; 26 detail.Attributes.Add("marginheight", "0") ; 27 detail.Attributes.Add("topmargin", "0") ; 28 detail.Attributes.Add("leftmargin", "0") ; 29 30 contents.Attributes.Add("NAME", "hauttop") ; 31 contents.Attributes.Add("MARGINHEIGHT", "0") ; 32 contents.Attributes.Add("MARGINWIDTH", "0") ; 33 contents.Attributes.Add("topmargin", "0") ; 34 contents.Attributes.Add("leftmargin", "0") ; 35 contents.Attributes.Add("SCROLLING", "no") ; 36 contents.Attributes.Add("framespacing", "0") ; 37 contents.Attributes.Add("frameborder", "0") ; 38 39 contents.Attributes.Add("src","default.aspx"); 40 main.Attributes.Add("NAME", "corpscentre") ; 41 main.Attributes.Add("MARGINHEIGHT", "0") ; 42 main.Attributes.Add("MARGINWIDTH", "0") ; 43 main.Attributes.Add("frameborder", "1") ; 44 main.Attributes.Add("SCROLLING", "auto") ; 45 main.Attributes.Add("framespacing", "0") ; 46 main.Attributes.Add("topmargin", "1") ; 47 main.Attributes.Add("leftmargin", "0") ; 48 49 main.Attributes.Add("src","Person.aspx"); 50 } 51 52 Web 窗体设计器生成的代码 72 } 73} 74

    本文来自云栖社区合作伙伴“doNET跨平台”,了解相关信息可以关注“opendotnet”微信公众号

    相关资源:七夕情人节表白HTML源码(两款)

    最新回复(0)