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
首先定义一个类:
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
相关文章推荐
- 关于VS2005 无法使用切换到设计视图的解决方法(转)
- 关于VS2005 无法使用切换到设计视图的解决方法
- 关于VS2005 无法使用切换到设计视图的解决方法
- 关于VS2005 无法使用切换到设计视图的解决方法
- VS2008使用问题,打开套用模板页后设计视图无内容显示但调试就有内容(已解决)
- 关于VS2005 无法使用切换到设计视图的解决方法
- 关于VS2005 无法使用切换到设计视图的解决方法 (winxp sp2)
- iOS设计中在视图中显示滚动汉字
- 关于在VS2005环境下无法从源视图切换到设计视图的解决方案
- Visual Studio 2005 无法显示设计视图的解决方法
- c#使用vtk(VTKDotNet)窗体设计器无法显示解决办法
- Thinkphp中使用display()方法显示视图模板,使用show()方法是显示文本内容
- 如何实现SDI程序使用CSplitterWnd创建的多个视图的动态地显示和关闭视图
- 使用嵌套的Repeater控件显示分级数据
- WPF 应用程序使用程序的模型视图 ViewModel 设计模式 WVVM
- SharePoint 2013 工作流设计之Designer 使用“可视化视图”
- 使用纯代码显示一个空白的视图
- Android-使用WebView视图显示网页
- 使用嵌套的Repeater控件显示分级数据
- [网络问题,截图以后再传]本实验是设计性实验。目的在于使用关系数据库标准语言SQL,掌握视图和索引的操作。