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 " >
<head runat= "server ">
<title> 无标题页 </title>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<iframe id= "up " frameborder= "0 " src= "Default1.aspx "> </iframe>
<iframe id= "down " frameborder= "0 " src= "Default2.aspx "> </iframe>
</div>
</form>
</body>
</html>
上框架内页面 Default1.aspx:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default1.aspx.cs " Inherits= "Default1 " %>
<!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>
<script type= "text/javascript ">
function ChangeTxt()
{
var txt = self.parent.frames[ "down "].window.document.all[ "TextBox1 "];
txt.value = document.all[ "TextBox1 "].value;
}
</script>
</head>
<body>
<form id= "form1 " runat= "server ">
<div>
<asp:TextBox ID= "TextBox1 " runat= "server "> test </asp:TextBox>
<asp:Button ID= "Button1 " runat= "server " Text= "Button " OnClientClick= "ChangeTxt(); " /> <br />
</div>
</form>
</body>
</html>
下框架内页面 Default2.aspx:
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Default2.aspx.cs " Inherits= "Default2 " %>
<!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>
<asp:TextBox ID= "TextBox1 " runat= "server "> </asp:TextBox>
</div>
</form>
</body>
</html>
[解决办法]
用别的方法,这样行不通!
[解决办法]
先学点东西,根据你学到的东西在成功的做法上作小步的、有道理的修改来获得成功操作。。