日期:2014-05-20  浏览次数:20383 次

VS2005中頁面間的調用
VS2005中頁面間的調用
                  我建兩個webform

page1.aspx

using   System;
using   System.Data;
using   Pagenamespace2;

namespace   Pagenamespace1;
{
        public   partial   class   page1:   System.Web.UI.Page
        {
                protected   void   Page_Load(object   sender,   EventArgs   e)
                {

                        page2   pag=new   page2();//這里寫的時候都沒有彈出有page2的類也不能這樣寫
                                                                          請問在VS2005中如何用頁面間的繼承問題。我想這樣能用page2的class怎么辦??
                                                                          不要說把page2.aspx.cs放在App_code中﹐我知道這樣可以﹐
                                                                          但在前面寫的CodeFile= "..\App_code\page2.aspx.cs "就不能訪問這個文件了。
                       
                }
        }
   
}

page2.aspx

using   System;
using   System.Data;
using   Pagenamespace1;

namespace   Pagenamespace2;
{
        public   partial   class   page2:   System.Web.UI.Page
        {
                protected   void   Page_Load(object   sender,   EventArgs   e)
                {
                      //                        
                }
        }
   
}

------解决方案--------------------
public partial class page1: page2
------解决方案--------------------
没法这么写.
------解决方案--------------------
为何要继承控件? 可不可以考虑把page2做成用户控件? 然后在page1里register?
------解决方案--------------------
如果你是用的上下框架的方式,那么你可以利用javascript来进行这个参数的传递
比如主界面
default.aspx:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default.aspx.cs " Inherits= "_Default " %>

<!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 " >