您的位置:首页 > 其它

VS2005中显示使用嵌套母版的设计视图

2008-07-02 10:45 162 查看
在VS2005中, 如果你的站点使用了嵌套母版,那么在设计一些使用这些嵌套母版的页面时,IDE默认的设置是只能使用源视图,而如果对于一些数据控件,就无法使用其智能标签了。所以,可以通过以下方法显示页面的设计视图。(如果你使用的VS2008,不存在这个问题)。

首先定义一个类:

BasePage.cs

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for BasePage
/// </summary>
public class BasePage : System.Web.UI.Page
{
private string runtimeMasterPageFile;

public string RuntimeMasterPageFile
{
get
{
return runtimeMasterPageFile;
}
set
{
runtimeMasterPageFile = value;
}
}

protected override void OnPreInit(EventArgs e)
{
if (runtimeMasterPageFile != null)
{
this.MasterPageFile = runtimeMasterPageFile;
}

base.OnPreInit(e);
}
}

然后可以使你的使用嵌套母版的页面的页面指令中,做如下声明:

<%@ Page Language="C#" MasterPageFile="" RuntimeMasterPageFile="~/UserLogedMasterPage.master" CodeFileBaseClass="BasePage" AutoEventWireup="true" CodeFile="Select.aspx.cs" Inherits="commonuser_Select" Title="交费记录查询" %>

注意:有一个MasterPageFile,值为空,还有一个RuntimeMasterPageFile,值是嵌套母版页。同时,还要让你的页面类继承自:BasePage,如:

public partial class commonuser_Select : BasePage
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: