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

本文介绍了一个基于 ASP.NET 的框架页实现方法,通过设置不同的框架属性来达到良好的页面布局效果。该框架包括两个主要部分:侧边栏和主要内容区域,详细展示了如何通过代码设置各框架元素的属性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下面是框架页:

<%@ 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

转载于:https://www.cnblogs.com/zhangyuhang3/p/6906051.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值