我新建一个aspx页面时没有将代码放在单独的文件中,怎么继承类呀?
我新建一个aspx页面时没有将代码放在单独的文件中,怎么继承类呀?
我怎么在aspx写代码不继承默认的page而是继承我自己的一个类呢?
希望大家给个简单的例子,谢谢了
我怎么在aspx写代码不继承默认的page而是继承我自己的一个类呢?
希望大家给个简单的例子,谢谢了
...全文
请发表友善的回复…
发表回复
Jinglecat 2009-02-06
- 打赏
- 举报
// .aspx
<%@ Page Language="C#" Inherits="MyPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
// App_Code/MyPage.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
/// <summary>
/// Summary description for MyPage
/// </summary>
public class MyPage : Page
{
protected override void OnLoad(EventArgs e)
{
Response.Write("hello");
base.OnLoad(e);
}
}
<%@ Page Language="C#" Inherits="MyPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
// App_Code/MyPage.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
/// <summary>
/// Summary description for MyPage
/// </summary>
public class MyPage : Page
{
protected override void OnLoad(EventArgs e)
{
Response.Write("hello");
base.OnLoad(e);
}
}
liujiayu10 2009-02-06
- 打赏
- 举报
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="xxx.aspx.cs" Inherits="xxx" %>
public partial class xxx : System.Web.UI.Page我姓区不姓区 2009-02-06
- 打赏
- 举报
3楼正解
我姓区不姓区 2009-02-06
- 打赏
- 举报
刚才没有仔细看你的问题,不好意思,我先去试试在答复你
DNN-2017 2009-02-06
- 打赏
- 举报
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="弹出div.aspx.cs" Inherits="div" %>
Inherits="你的类"不过你到类也要继承page类的
Inherits="你的类"不过你到类也要继承page类的
hanbingb 2009-02-06
- 打赏
- 举报
不太明白楼上的意思
可以再详细点么?
可以再详细点么?
我姓区不姓区 2009-02-06
- 打赏
- 举报
把Page类换成你要继承的类不就可以了