Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 在子页面中扩展母版页类_Asp.net_Master Pages_Code Behind - Fatal编程技术网

Asp.net 在子页面中扩展母版页类

Asp.net 在子页面中扩展母版页类,asp.net,master-pages,code-behind,Asp.net,Master Pages,Code Behind,我正在用ASP.NET/C编写一个网站。我使用母版页来简化布局设计 我有一个BaseMasterPage.MasterPage,它在一个.master.cs文件中有一些代码,其中定义了BaseMasterPage类(扩展System.Web.UI.MasterPage)和其中的一些方法(page_load,…)。我想做的是,让一个子页面具有一个扩展BaseMasterPage的关联ChildPage类,以便重用BaseMasterPage中的一些方法 但这会带来一些错误。例如,ASP.child

我正在用ASP.NET/C编写一个网站。我使用母版页来简化布局设计

我有一个BaseMasterPage.MasterPage,它在一个.master.cs文件中有一些代码,其中定义了BaseMasterPage类(扩展System.Web.UI.MasterPage)和其中的一些方法(page_load,…)。我想做的是,让一个子页面具有一个扩展BaseMasterPage的关联ChildPage类,以便重用BaseMasterPage中的一些方法

但这会带来一些错误。例如,ASP.child_aspx.GetTypeHashCode():找不到用于覆盖的匹配方法,与ASP.child_aspx.ProcessRequest(System.Web.HttpContext)相同,ASP.login_aspx不实现字段System.Web.IHttpHandler.IsReusable等

我对ASP.NET很陌生,所以我想这只是一个初学者的错误。。。谁能告诉我我做错了什么


提前感谢您的回答。

我想您可以这样定义子页面的类:

公共部分类默认值:ChildPageClass

在您的ChildPageClass中:

公共类ChildPageClass:YourMasterPageClass

你能试试这个吗


我不确定这个解决方案。

页面和母版页是不同类型的东西。您遇到问题,因为ASPX页面无法从System.Web.UI.MasterPage继承。它最终应该继承自System.Web.UI.Page


因此,让母版页和内容页(aspx)从同一基类继承的计划将不起作用。

感谢您的澄清。我对母版页和内容页有点困惑,但我现在可以工作了。