本文介绍了将类库中的类引用给Aspx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建带代码的aspx页面作为类文件,该文件位于类库(即预编译的类)中.
Hi,
i want to create aspx page with code behind as a class file, which is located in class library,ie, precompiled class.
推荐答案
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MyPage : MyLibraryPage
{
}
MyLibraryPage.cs文件:
MyLibraryPage.cs file:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LibraryPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Form.InnerHtml = "Hello world!";
}
}
yeah i too surprised, just look into the code
here is my aspx page without aspx.cs and aspx.designer.cs :
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RefereClassLibrary.aspx.cs"
Inherits="BaseClassLibrary.RefereClassLibrary" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<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>
和ClassLibrary中的类:
and class in ClassLibrary:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class LibraryPage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Form.InnerHtml = "Hello world!";
}
}
然后我将我的类库引用到Project.最终得到了解决方案.
and i referred my Class Library to Project.finally got the solution.
这篇关于将类库中的类引用给Aspx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!