一个aspx.cs类中怎样访问另一个aspx.cs类中的方法与属性? 在一个aspx.cs中引用另一个aspx.cs的命名空间,然后再new实例化另一个aspx.cs类 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 我加了它会报错:编译错误 说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: ASPNET: 请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如 Page 或 UserControl)是正确的。源错误: 行 11: namespace abc行 12: {行 13: public partial class _Default : System.Web.UI.Page行 14: {行 15: public static DataTable dt; 源文件: e:\session传值\Default.aspx.cs 行: 13 应该在A页,继承完Page之后,再继承你的另一个页面类。 "simson2010",asp.net中不支持多重继承的 在B页面中加入一个静态方法, public static Method();然后在A页面或者其它同一个Namespace下的页面中用 namespace.clsssname.staticMethod()的形式调用即可.页1-----------------namespace c1{ public partial class WebTest1 : System.Web.UI.Page { [AjaxPro.AjaxMethod] public string GetServerTime() { return DateTime.Now.ToString(); } protected void Page_Load(object sender, EventArgs e) { AjaxPro.Utility.RegisterTypeForAjax(typeof(c1.WebTest1)); } //protected override void InitializeCulture() // { // base.InitializeCulture(); // Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]); // Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0]); // } protected void Button1_Click(object sender, EventArgs e) { string a = c1._Default3.getString(8); Response.Write(a); } }}页2-------------------namespace c1{ public partial class _Default3 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.Write(getString(8)); } public static string getString(int p) { return p.ToString(); } }}--------------------页面控件自己重新弄一下 忘记了,那些AjaxPro的东东都删掉 由于ASP.net 2.0的页面对应的.aspx.cs的类在运行时已经被实例化,不能用new创建,但可以调用该类的静态成员方法.或者将页面和CS代码放至于App_Code目录中,这样就能将其再实例化(未测试过). 为什么不把共用的方法或类独立出来呢?在一个aspx.cs中调用另一个aspx.cs中的方法从设计上就有问题。 unity中,有谁用过构造函数注入. FCKeditor 2.4.3 版以上传文件吗? 关于vs2008里的web.config文件 散分,顺便收集正则表达式! 一个金额转中文大写的源代码出现了一点小问题,希望大家帮忙(有源码) 求助:如何实现类似MS Project风格的可伸展的Dategrid或者DateList或者其他的.... datagrid 点击编辑后取消时出现的问题 烦请高手提供treeview的完整代码! 如何能实现直接调用应用软件? 表头,表体的问题?在线等待 ListBox点击定位问题 用asp.net+vb.net 调用word
编译错误
说明: 在编译向该请求提供服务所需资源的过程中出现错误。请检查下列特定错误详细信息并适当地修改源代码。 编译器错误信息: ASPNET: 请确保此代码文件中定义的类与“inherits”属性匹配,并且该类扩展的基类(例如 Page 或 UserControl)是正确的。源错误: 行 11: namespace abc
行 12: {
行 13: public partial class _Default : System.Web.UI.Page
行 14: {
行 15: public static DataTable dt;
源文件: e:\session传值\Default.aspx.cs 行: 13
然后在A页面或者其它同一个Namespace下的页面中用 namespace.clsssname.staticMethod()的形式调用即可.
页1
-----------------
namespace c1
{
public partial class WebTest1 : System.Web.UI.Page
{
[AjaxPro.AjaxMethod]
public string GetServerTime()
{
return DateTime.Now.ToString();
}
protected void Page_Load(object sender, EventArgs e)
{
AjaxPro.Utility.RegisterTypeForAjax(typeof(c1.WebTest1)); } //protected override void InitializeCulture()
// {
// base.InitializeCulture();
// Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);
// Thread.CurrentThread.CurrentUICulture = new CultureInfo(Request.UserLanguages[0]);
// }
protected void Button1_Click(object sender, EventArgs e)
{
string a = c1._Default3.getString(8);
Response.Write(a);
}
}
}
页2-------------------namespace c1
{
public partial class _Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Response.Write(getString(8));
}
public static string getString(int p)
{
return p.ToString();
}
}}--------------------
页面控件自己重新弄一下